ansible 安裝nginx

---
- hosts: web
  vars:
    - nginx_version: 1.16.1
    - nginx_user: nginx
  tasks:
    - name: add nginx run user
      user: name={{ nginx_user }}
    - name: nginx dependence
      yum: name={{ item }} state=latest
      with_items:
        - openssl-devel
        - pcre-devel
        - zlib-devel
        - gcc-c++
        - wget
    - name: download nginx-{{ nginx_version }}.tar.gz
      get_url:
        url: http://nginx.org/download/nginx-{{ nginx_version }}.tar.gz
        dest: "{{ lookup('env','HOME') }}/nginx-{{ nginx_version }}.tar.gz"
    - name: install nginx
      shell: cd {{ lookup('env','HOME') }};tar -xf nginx-{{ nginx_version }}.tar.gz;cd nginx-{{ nginx_version }};./configure --user={{ nginx_user }} --group={{ nginx_user }} --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-http_realip_module;make -j`grep processor /proc/cpuinfo |wc -l`&& make install
    - name: start nginx services
      shell: /usr/local/nginx/sbin/nginx

ansible-playbook ./nginx.yaml

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章