Ansible自动化安装Nginx
我的配置:
/etc/hosts:
/etc/ansible/hosts:
nglinx安装包:
ansible自动化安装nginx:
1.安装ansible。
2.创建目录结构:
mkdir -p /ansible/roles/nginx/{defaults,files,handlers,meta,tasks,templates,vars}
3.install_nginx.sh:
#!/bin/bash yum -y install zlib zlib-devel openssl openssl-devel pcre-devel groupadd -r nginx useradd -s /sbin/nologin -g nginx -r nginx cd /tmp tar xf nginx-1.9.9.tar.gz;cd nginx-1.9.9 mkdir /var/run/nginx/;chown nginx.nginx /var/run/nginx/ ./configure \ --prefix=/usr \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --pid-path=/var/run/nginx/nginx.pid \ --user=nginx \ --group=nginx \ --with-http_ssl_module make && make install sed "/^\s*index / i proxy_pass http://localhost:8080;" /etc/nginx/nginx.conf /usr/sbin/nginx sed
4.main.yml:
- name: copy nginx_tar_gz to client copy: src=nginx-1.9.9.tar.gz dest=/tmp/nginx-1.9.9.tar.gz - name: copy install_shell to client copy: src=install_nginx.sh dest=/tmp/install_nginx.sh - name: install nginx shell: /bin/bash /tmp/install_nginx.sh
5.webservice.yml:
- hosts: Hadoop remote_user: root roles: - nginx
6.执行安装:
cd /ansible ansible-playbook webservice.yml
安装成功!
7.进入test2下检查:
到这里就全部结束了!
Ansible 的详细介绍:请点这里
Ansible 的下载地址:请点这里
相关推荐
laisean 2020-09-27
onepiecedn 2020-10-29
guchengxinfen 2020-10-12
houdaiye 2020-09-23
逆时针 2020-08-19
pzczyy 2020-08-19
annan 2020-08-02
hpujsj 2020-07-26
annan 2020-07-18
逆时针 2020-06-21
annan 2020-06-20
逆时针 2020-06-14
逆时针 2020-06-14
awoyaoc 2020-06-12
逆时针 2020-06-09
piaotiejun 2020-06-07
awoyaoc 2020-06-07