apache2.yml 3.8 KB

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