ansible playbook进阶之nginx部署及优化

ansible-playbook进阶之nginx部署及优化

Playbook 示范:

[root@ansible ~]# vim  nginx.yml--Virtual Machine--★ 
---
- hosts: web
  remote_user: root
  tasks: 
    - yum: 
        name: "{{item}}"
      with_items: ["gcc" ,"make" ,"openssl-devel" ,"pcre-devel" ,"zlib-devel","wget","mariadb-server","php-mysql"]
    - shell: 
        wget https://github.com/TANRONGSheng/openstack/blob/master/lnmp_soft/nginx-1.12.2.tar.gz
    - shell: 
        wget https://github.com/TANRONGSheng/openstack/blob/master/lnmp_soft/php-fpm-5.4.16-42.el7.x86_64.rpm
    - yum: 
        name: php-fpm-5.4.16-42.el7.x86_64.rpm
    - service: 
        name: mariadb
        state: started 
        enabled: yes
    - service: 
        name: php-fpm
        state: started
        enabled: yes
    - shell: 
        tar xf  /root/nginx-1.12.2.tar.gz
    - user:
        name: nginx
        shell: /sbin/nologin
    - script: /root/nginx.sh
    - copy:
        src: /root/nginx.conf
        dest: /usr/local/nginx/conf/nginx.conf
        owner: nginx
        group: nginx
        mode: 0644
    - shell: 
        nginx

这里面引用的nginx的相应配置文件自备

测试结果:

[root@ansible ~]#  curl -i   http://web1/
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 19 Apr 2020 12:56:00 GMT
Content-Type: text/html; charset=koi8-r
Content-Length: 72
Last-Modified: Fri, 19 Apr 2020 12:55:54 GMT
Connection: keep-alive
ETag: "5cb9c55a-48"
Accept-Ranges: bytes

O_o  --->  Ansible -playbook advanced nginx deployment and optimization
[root@ansible ~]#  curl -i   http://web2/
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 19 Apr 2020 12:56:12 GMT
Content-Type: text/html; charset=koi8-r
Content-Length: 72
Last-Modified: Fri, 19 Apr 2020 12:55:54 GMT
Connection: keep-alive
ETag: "5cb9c55a-48"
Accept-Ranges: bytes

O_o  --->  Ansible -playbook advanced nginx deployment and optimization
发布了96 篇原创文章 · 获赞 100 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43395428/article/details/104933350
今日推荐