123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- ---
- # - name : Include Systembase Yum Install Roles
- # include_role:
- # name: systembase
- # tasks_from: packages
- # tags: nginx_installer
- - name : Include Systembase Sysctl Configurtion Roles
- include_role:
- name: systembase
- tasks_from: sysctl
- tags: nginx_installer
-
- - name: Install Library On Ubuntu
- apt: "name={{ item }} state=latest"
- with_items:
- - unzip
- - build-essential
- - libreadline-dev
- - libncurses5-dev
- - libpcre3-dev
- - libssl-dev
- - git
- - perl
- - make
- - libjemalloc-dev
- - daemon
- when: ansible_distribution == 'Ubuntu'
- tags: nginx_installer
- - name: Install Library On CentOS
- yum: "name={{ item }} state=latest"
- with_items:
- - unzip
- - readline-devel
- - pcre-devel
- - openssl-devel
- - gcc
- - gcc-c++
- when: ansible_distribution == 'CentOS'
- tags: nginx_installer
- - name: Get PCPE Version Of RPM
- shell: yum list installed pcre-devel | grep pcre-devel | awk '{print $2}' | cut -d'-' -f1
- register: pcre_version
- changed_when: False
- args:
- warn: no
- tags: nginx_installer
- - name: Copy PCRE Library On CentOS6
- copy: src=pcre-8.41.zip dest=/opt/pcre-8.41.zip owner=root group=root mode=0444
- when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
- tags: nginx_installer
- - name: Unzip PCRE Library
- unarchive:
- src: /opt/pcre-8.41.zip
- dest: /opt/
- remote_src: yes
- when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
- tags: nginx_installer
- #- name: Define Variable For PCRE
- #vars:
- # pcre_path: "/opt/pcre-8.41"
- # when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
- # tags: nginx_installer
-
- - group:
- name: nginx
- state: present
- tags: nginx_installer
- - user:
- name: nginx
- shell: /sbin/nologin
- group: nginx
- tags: nginx_installer
- - name: Copy Source Package
- copy: src=openresty-{{ openresty_version }}.tar.gz dest=/root/openresty-{{ openresty_version }}.tar.gz owner=root group=root mode=0644
- tags: nginx_installer
- - name: Copy Install Stript When Pcre_version Less Than 8.4
- template: src=openresty.sh dest=/root/openresty.sh owner=root group=root mode=0444
- vars:
- pcre_path: "/opt/pcre-8.41"
- tags: nginx_installer
- when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
- - name: Copy Install Stript
- template: src=openresty.sh dest=/root/openresty.sh owner=root group=root mode=0444
- tags: nginx_installer
- when: pcre_version.stdout_lines > '8.4' or ansible_distribution == 'Ubuntu'
- - name: Copy Service
- copy: src=nginxd dest=/etc/init.d/nginxd owner=root group=root mode=0744
- tags: nginx_installer
- - name: Run Installer
- shell: bash /root/openresty.sh
- tags: nginx_installer
- - name: Create Cache Directory
- file:
- path: "{{ item }}"
- state: directory
- mode: 0755
- with_items:
- - "/usr/local/openresty/nginx/cache/proxy_cache"
- - "/usr/local/openresty/nginx/cache/temp_path"
- - "/usr/local/openresty/nginx/cache/fastcgi_cache"
- - "/usr/local/openresty/nginx/conf/vhost"
- - "/usr/local/openresty/nginx/run"
- tags: nginx_installer
- - name: Copy nginx.conf
- template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf owner=root group=root mode=0644
- tags: nginx_installer
- - name: Create Empty Deny File
- file:
- path: /usr/local/openresty/nginx/conf/deny.ip
- state: touch
- mode: 0644
- tags: nginx_installer
- #- name: Create Empty Run Path
- # file:
- # path: /usr/local/openresty/nginx/run
- # state: directory
- # mode: 0755
- - name: Remove Pid File & Temp Files
- file:
- path: "{{ item }}"
- state: absent
- with_items:
- - "/run/nginx.pid"
- - "/root/openresty-1.11.2.4"
- - "/root/openresty-1.11.2.4.tar.gz"
- - "/root/openresty.sh"
- - "/opt/pcre-8.41"
- tags: nginx_installer
-
- - name: Nginx Service Enable
- service:
- name: nginxd
- enabled: yes
- #- name: Starting Nginx Process
- # shell: /etc/init.d/nginxd start
|