nginx.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. - name: 'Install nginx package'
  2. apt:
  3. pkg: 'nginx'
  4. state: 'installed'
  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. - name: 'Install PHPMyAdmin virtual host for nginx (sites-available)'
  105. template:
  106. src: 'nginx/pma_vhost.j2'
  107. dest: '/etc/nginx/sites-available/pma'
  108. owner: 'root'
  109. group: 'root'
  110. mode: '0644'
  111. notify:
  112. - 'Reload nginx'
  113. when: with_phpmyadmin
  114. - name: 'Install PHPMyAdmin virtual host for nginx (sites-enabled)'
  115. file:
  116. src: '/etc/nginx/sites-available/pma'
  117. path: '/etc/nginx/sites-enabled/pma'
  118. state: 'link'
  119. notify:
  120. - 'Reload nginx'
  121. when: with_phpmyadmin
  122. - name: 'Install PHPPgAdmin virtual host for nginx (sites-available)'
  123. template:
  124. src: 'nginx/pga_vhost.j2'
  125. dest: '/etc/nginx/sites-available/pga'
  126. owner: 'root'
  127. group: 'root'
  128. mode: '0644'
  129. notify:
  130. - 'Reload nginx'
  131. when: with_phppgadmin
  132. - name: 'Install PHPPgAdmin virtual host for nginx (sites-enabled)'
  133. file:
  134. src: '/etc/nginx/sites-available/pga'
  135. path: '/etc/nginx/sites-enabled/pga'
  136. state: 'link'
  137. notify:
  138. - 'Reload nginx'
  139. when: with_phppgadmin
  140. - name: 'Install PHP system checks virtual host for nginx (sites-available)'
  141. template:
  142. src: 'nginx/sys_vhost.j2'
  143. dest: '/etc/nginx/sites-available/sys'
  144. owner: 'root'
  145. group: 'root'
  146. mode: '0644'
  147. notify:
  148. - 'Reload nginx'
  149. when: with_php
  150. - name: 'Install PHP system checks virtual host for nginx (sites-enabled)'
  151. file:
  152. src: '/etc/nginx/sites-available/sys'
  153. path: '/etc/nginx/sites-enabled/sys'
  154. state: 'link'
  155. notify:
  156. - 'Reload nginx'
  157. when: with_php
  158. - name: 'Ensure nginx is running'
  159. service:
  160. name: 'nginx'
  161. state: 'started'