nginx.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. - name: 'Install nginx package'
  2. apt:
  3. pkg: 'nginx'
  4. state: 'present'
  5. - name: 'Install logrotate configuration for nginx'
  6. template:
  7. src: 'logrotate/nginx.j2'
  8. dest: '/etc/logrotate.d/nginx'
  9. owner: 'root'
  10. group: 'root'
  11. mode: '0644'
  12. - name: 'Install nginx default file configuration'
  13. template:
  14. src: 'nginx/default.j2'
  15. dest: '/etc/default/nginx'
  16. owner: 'root'
  17. group: 'root'
  18. mode: '0644'
  19. notify:
  20. - 'Restart nginx'
  21. - name: 'Install custom mime types for nginx'
  22. template:
  23. src: 'nginx/mime.types.custom.j2'
  24. dest: '/etc/nginx/mime.types.custom'
  25. owner: 'root'
  26. group: 'root'
  27. mode: '0644'
  28. notify:
  29. - 'Restart nginx'
  30. - name: 'Install nginx configuration'
  31. template:
  32. src: 'nginx/nginx.conf.j2'
  33. dest: '/etc/nginx/nginx.conf'
  34. owner: 'root'
  35. group: 'root'
  36. mode: '0644'
  37. notify:
  38. - 'Restart nginx'
  39. - name: 'Install additional nginx configuration params (conf.d/)'
  40. template:
  41. src: 'nginx/conf.d/{{ item }}.conf.j2'
  42. dest: '/etc/nginx/conf.d/{{ item }}.conf'
  43. owner: 'root'
  44. group: 'root'
  45. mode: '0644'
  46. with_items:
  47. - 'status'
  48. notify:
  49. - 'Reload nginx'
  50. - name: 'Install additional nginx configuration params (vhost_*)'
  51. template:
  52. src: 'nginx/vhost_{{ item }}.j2'
  53. dest: '/etc/nginx/vhost_{{ item }}'
  54. owner: 'root'
  55. group: 'root'
  56. mode: '0644'
  57. with_items:
  58. - 'all'
  59. - 'expires'
  60. - 'cache-fd'
  61. - 'protect-files'
  62. - 'security'
  63. notify:
  64. - 'Reload nginx'
  65. - name: 'Install SSL vhost configuration for Nginx'
  66. template:
  67. src: 'nginx/vhost_ssl.j2'
  68. dest: '/etc/nginx/vhost_ssl-{{ item }}'
  69. owner: 'root'
  70. group: 'root'
  71. mode: '0644'
  72. with_items: '{{ ssl_certs }}'
  73. notify:
  74. - 'Reload nginx'
  75. when: ssl_certs
  76. - name: 'Install SSL vhost configuration for Nginx (Lets Encrypt certificates)'
  77. template:
  78. src: 'nginx/vhost_ssl_auto.j2'
  79. dest: '/etc/nginx/vhost_ssl_auto-{{ item.split(" ")[0] }}'
  80. owner: 'root'
  81. group: 'root'
  82. mode: '0644'
  83. with_items: '{{ ssl_certs_auto }}'
  84. notify:
  85. - 'Reload nginx'
  86. when: ssl_certs_auto
  87. - name: 'Install Let Encrypt configuration for Nginx'
  88. template:
  89. src: 'nginx/letsencrypt.j2'
  90. dest: '/etc/nginx/letsencrypt'
  91. owner: 'root'
  92. group: 'root'
  93. mode: '0644'
  94. notify:
  95. - 'Reload nginx'
  96. when: ssl_certs_auto
  97. - name: 'Create basic authentication file for admin (Nginx)'
  98. template:
  99. src: 'nginx/auth_admin.j2'
  100. dest: '/etc/nginx/auth_admin'
  101. owner: 'root'
  102. group: 'www-data'
  103. mode: '0640'
  104. when: http_auth_admin_password is defined and http_auth_admin_password
  105. - name: 'Install PHPMyAdmin virtual host for nginx (sites-available)'
  106. template:
  107. src: 'nginx/pma_vhost.j2'
  108. dest: '/etc/nginx/sites-available/pma'
  109. owner: 'root'
  110. group: 'root'
  111. mode: '0644'
  112. notify:
  113. - 'Reload nginx'
  114. when: with_phpmyadmin
  115. - name: 'Install PHPMyAdmin virtual host for nginx (sites-enabled)'
  116. file:
  117. src: '/etc/nginx/sites-available/pma'
  118. path: '/etc/nginx/sites-enabled/pma'
  119. state: 'link'
  120. notify:
  121. - 'Reload nginx'
  122. when: with_phpmyadmin
  123. - name: 'Install PHPPgAdmin virtual host for nginx (sites-available)'
  124. template:
  125. src: 'nginx/pga_vhost.j2'
  126. dest: '/etc/nginx/sites-available/pga'
  127. owner: 'root'
  128. group: 'root'
  129. mode: '0644'
  130. notify:
  131. - 'Reload nginx'
  132. when: with_phppgadmin
  133. - name: 'Install PHPPgAdmin virtual host for nginx (sites-enabled)'
  134. file:
  135. src: '/etc/nginx/sites-available/pga'
  136. path: '/etc/nginx/sites-enabled/pga'
  137. state: 'link'
  138. notify:
  139. - 'Reload nginx'
  140. when: with_phppgadmin
  141. - name: 'Install PHP system checks virtual host for nginx (sites-available)'
  142. template:
  143. src: 'nginx/sys_vhost.j2'
  144. dest: '/etc/nginx/sites-available/sys'
  145. owner: 'root'
  146. group: 'root'
  147. mode: '0644'
  148. notify:
  149. - 'Reload nginx'
  150. when: with_php
  151. - name: 'Install PHP system checks virtual host for nginx (sites-enabled)'
  152. file:
  153. src: '/etc/nginx/sites-available/sys'
  154. path: '/etc/nginx/sites-enabled/sys'
  155. state: 'link'
  156. notify:
  157. - 'Reload nginx'
  158. when: with_php
  159. - name: 'Ensure nginx is running'
  160. service:
  161. name: 'nginx'
  162. state: 'started'