installer.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. when: ansible_distribution == 'CentOS'
  37. tags: nginx_installer
  38. - name: Get PCPE Version Of RPM
  39. shell: yum list installed pcre-devel | grep custom-rpm | awk '{print $2}' | cut -d'-' -f1
  40. register: pcre_version
  41. changed_when: False
  42. args:
  43. warn: no
  44. tags: nginx_installer
  45. - name: Copy PCRE Library On CentOS6
  46. copy: src=pcre-8.41.zip dest=/opt/pcre-8.41.zip owner=root group=root mode=0444
  47. when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
  48. tags: nginx_installer
  49. - name: Unzip PCRE Library
  50. unarchive:
  51. src: /opt/pcre-8.41.zip
  52. dest: /opt/
  53. remote_src: yes
  54. when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
  55. tags: nginx_installer
  56. #- name: Define Variable For PCRE
  57. #vars:
  58. # pcre_path: "/opt/pcre-8.41"
  59. # when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
  60. # tags: nginx_installer
  61. - group:
  62. name: nginx
  63. state: present
  64. tags: nginx_installer
  65. - user:
  66. name: nginx
  67. shell: /sbin/nologin
  68. group: nginx
  69. tags: nginx_installer
  70. - name: Copy Source Package
  71. copy: src=openresty-{{ openresty_version }}.tar.gz dest=/root/openresty-{{ openresty_version }}.tar.gz owner=root group=root mode=0644
  72. tags: nginx_installer
  73. - name: Copy Install Stript When Pcre_version Less Than 8.4
  74. template: src=openresty.sh dest=/root/openresty.sh owner=root group=root mode=0444
  75. vars:
  76. pcre_path: "/opt/pcre-8.41"
  77. tags: nginx_installer
  78. when: pcre_version.stdout_lines < '8.4' and ansible_distribution == 'CentOS'
  79. - name: Copy Install Stript
  80. template: src=openresty.sh dest=/root/openresty.sh owner=root group=root mode=0444
  81. tags: nginx_installer
  82. when: pcre_version.stdout_lines > '8.4' or ansible_distribution == 'Ubuntu'
  83. - name: Copy Service
  84. copy: src=nginxd dest=/etc/init.d/nginxd owner=root group=root mode=0744
  85. tags: nginx_installer
  86. - name: Run Installer
  87. shell: bash /root/openresty.sh
  88. tags: nginx_installer
  89. - name: Create Cache Directory
  90. file:
  91. path: "{{ item }}"
  92. state: directory
  93. mode: 0755
  94. with_items:
  95. - "/usr/local/openresty/nginx/cache/proxy_cache"
  96. - "/usr/local/openresty/nginx/cache/temp_path"
  97. - "/usr/local/openresty/nginx/cache/fastcgi_cache"
  98. - "/usr/local/openresty/nginx/conf/vhost"
  99. - "/usr/local/openresty/nginx/run"
  100. tags: nginx_installer
  101. - name: Copy nginx.conf
  102. template: src=nginx.conf dest=/usr/local/openresty/nginx/conf/nginx.conf owner=root group=root mode=0644
  103. tags: nginx_installer
  104. - name: Create Empty Deny File
  105. file:
  106. path: /usr/local/openresty/nginx/conf/deny.ip
  107. state: touch
  108. mode: 0644
  109. tags: nginx_installer
  110. #- name: Create Empty Run Path
  111. # file:
  112. # path: /usr/local/openresty/nginx/run
  113. # state: directory
  114. # mode: 0755
  115. - name: Remove Pid File & Temp Files
  116. file:
  117. path: "{{ item }}"
  118. state: absent
  119. with_items:
  120. - "/run/nginx.pid"
  121. - "/root/openresty-1.11.2.4"
  122. - "/root/openresty-1.11.2.4.tar.gz"
  123. - "/root/openresty.sh"
  124. - "/opt/pcre-8.41"
  125. tags: nginx_installer
  126. - name: Nginx Service Enable
  127. service:
  128. name: nginxd
  129. enabled: yes
  130. #- name: Starting Nginx Process
  131. # shell: /etc/init.d/nginxd start