nginx.yml 3.8 KB

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