apache2.yml 4.7 KB

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