1、准备安装包
nginx-1.22.0.tar.gz(地址:https://nginx.org/download/)
2、编写剧本
vim nginx.yml
【
---
- hosts: 192.168.59.103
remote_user: root
tasks:
- name: mkdir
file: name=/data/nginx state=directory
- name: copy file
copy: src=/data/nginx/nginx-1.22.0.tar.gz dest=/data/nginx
- name: tar
unarchive: src=/data/nginx/nginx-1.22.0.tar.gz dest=/data/nginx copy=no
- name: yum
yum: name=gcc,pcre-devel,zlib-devel,openssl,openssl-devel
- name: configure
shell: cd /data/nginx/nginx-1.22.0/ && ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.22.0/ --with-http_stub_status_module --with-http_ssl_module && make &&make install
- name: link
shell: ln -s /usr/local/nginx-1.22.0 /usr/local/nginx
- name: user
user: shell=/sbin/nologin name=nginx
- name: start
shell: /usr/local/nginx/sbin/nginx
】
3、验证
ansible-playbook nginx.yml
有一个警告,link有专门的模块,但是不要紧,用shell也可以
标签:shell,name,编译,--,nginx,ansible,1.22,data From: https://www.cnblogs.com/leihongnu/p/16733489.html