nginx.yml 4.7 KB

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