installer.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. ---
  2. # - name : Include Systembase Yum Install Roles
  3. # include_role:
  4. # name: systembase
  5. # tasks_from: packages
  6. # tags: nginx_installer
  7. - name : Include Systembase Sysctl Configurtion Roles
  8. include_role:
  9. name: systembase
  10. tasks_from: sysctl
  11. tags: nginx_installer
  12. - name: Install Library On Ubuntu
  13. apt: "name={{ item }} state=latest"
  14. with_items:
  15. - unzip
  16. - build-essential
  17. - libreadline-dev
  18. - libncurses5-dev
  19. - libpcre3-dev
  20. - libssl-dev
  21. - git
  22. - perl
  23. - make
  24. - libjemalloc-dev
  25. - daemon
  26. when: ansible_distribution == 'Ubuntu'
  27. tags: nginx_installer
  28. - name: Install Library On CentOS
  29. yum: "name={{ item }} state=latest"
  30. with_items:
  31. - unzip
  32. - readline-devel
  33. - pcre-devel
  34. - openssl-devel
  35. - gcc
  36. - gcc-c++
  37. when: ansible_distribution == 'CentOS'
  38. tags: nginx_installer
  39. - name: Get PCPE Version Of RPM
  40. shell: yum list installed pcre-devel | grep pcre-devel | awk '{print $2}' | cut -d'-' -f1
  41. register: pcre_version
  42. changed_when: False
  43. args:
  44. warn: no
  45. tags: nginx_installer
  46. - name: Copy PCRE Library On CentOS6
  47. copy: src=pcre-8.41.zip dest=/opt/pcre-8.41.zip owner=root group=root mode=0444
  48. when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
  49. tags: nginx_installer
  50. - name: Unzip PCRE Library
  51. unarchive:
  52. src: /opt/pcre-8.41.zip
  53. dest: /opt/
  54. remote_src: yes
  55. when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
  56. tags: nginx_installer
  57. #- name: Define Variable For PCRE
  58. #vars:
  59. # pcre_path: "/opt/pcre-8.41"
  60. # when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
  61. # tags: nginx_installer
  62. - group:
  63. name: nginx
  64. state: present
  65. tags: nginx_installer
  66. - user:
  67. name: nginx
  68. shell: /sbin/nologin
  69. group: nginx
  70. tags: nginx_installer
  71. - name: Copy Source Package
  72. copy: src=openresty-{{ openresty_version }}.tar.gz dest=/root/openresty-{{ openresty_version }}.tar.gz owner=root group=root mode=0644
  73. tags: nginx_installer
  74. - name: Copy Install Stript When Pcre_version Less Than 8.4
  75. template: src=openresty.sh dest=/root/openresty.sh owner=root group=root mode=0444
  76. vars:
  77. pcre_path: "/opt/pcre-8.41"
  78. tags: nginx_installer
  79. when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
  80. - name: Copy Install Stript
  81. template: src=openresty.sh dest=/root/openresty.sh owner=root group=root mode=0444
  82. tags: nginx_installer
  83. when: pcre_version.stdout_lines > '8.4' or ansible_distribution == 'Ubuntu'
  84. - name: Copy Service
  85. copy: src=nginxd dest=/etc/init.d/nginxd owner=root group=root mode=0744
  86. tags: nginx_installer
  87. - name: Run Installer
  88. shell: bash /root/openresty.sh
  89. tags: nginx_installer
  90. - name: Create Cache Directory
  91. file:
  92. path: "{{ item }}"
  93. state: directory
  94. mode: 0755
  95. with_items:
  96. - "/usr/local/openresty/nginx/cache/proxy_cache"
  97. - "/usr/local/openresty/nginx/cache/temp_path"
  98. - "/usr/local/openresty/nginx/cache/fastcgi_cache"
  99. - "/usr/local/openresty/nginx/conf/vhost"
  100. - "/usr/local/openresty/nginx/run"
  101. tags: nginx_installer
  102. - name: Copy nginx.conf
  103. template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf owner=root group=root mode=0644
  104. tags: nginx_installer
  105. - name: Create Empty Deny File
  106. file:
  107. path: /usr/local/openresty/nginx/conf/deny.ip
  108. state: touch
  109. mode: 0644
  110. tags: nginx_installer
  111. #- name: Create Empty Run Path
  112. # file:
  113. # path: /usr/local/openresty/nginx/run
  114. # state: directory
  115. # mode: 0755
  116. - name: Remove Pid File & Temp Files
  117. file:
  118. path: "{{ item }}"
  119. state: absent
  120. with_items:
  121. - "/run/nginx.pid"
  122. - "/root/openresty-1.11.2.4"
  123. - "/root/openresty-1.11.2.4.tar.gz"
  124. - "/root/openresty.sh"
  125. - "/opt/pcre-8.41"
  126. tags: nginx_installer
  127. - name: Nginx Service Enable
  128. service:
  129. name: nginxd
  130. enabled: yes
  131. #- name: Starting Nginx Process
  132. # shell: /etc/init.d/nginxd start