apache2.yml 4.6 KB

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