-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_openresty.yml
47 lines (40 loc) · 1.34 KB
/
install_openresty.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 安装openresty
# 剧本作用: 使用rpm方式安装openresty
# 安装命令: ansible-playbook -i hosts install_openresty.yml
# 配置文件: /usr/local/openresty/nginx/conf/nginx.conf
- hosts: all
vars:
# 安装包名称
tarball: openresty-1.21.4.2.tgz
# 本地安装包位置
localPath: ~/developer/software/openresty
target: /opt/soft
tasks:
# 创建安装目录
- name: create installation directory
file:
path: "{{ target }}"
state: directory
# 上传rpm包到远程主机
- name: upload tarball
copy: src={{ localPath }}/{{ tarball }} dest={{ target }}
# 解压安装包
- name: Decompressing files
shell: chdir={{ target }} tar zxvf {{ tarball }}
# 安装RPM包
- name: Install
shell: chdir=/opt/soft/openresty-1.21.4.2/ /usr/bin/rpm -ivh {{ item }} --force --nodeps
with_items:
- "openresty-zlib-1.2.12-1.el7.x86_64.rpm"
- "openresty-openssl111-1.1.1n-1.el7.x86_64.rpm"
- "openresty-pcre-8.45-1.el7.x86_64.rpm"
- "openresty-1.21.4.2-1.el7.x86_64.rpm"
# 清理安装包
- name: clean tarball
shell: chdir=/opt/soft/ rm -rf openresty-*
# 启动openresty并设置开机启动
- name: start and enable redis.
service:
name: openresty.service
state: started
enabled: True