apache2.yml 4.2 KB

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