nginx.yml 3.6 KB

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