apache2.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. - name: 'Install Apache2 packages'
  2. apt:
  3. pkg: 'apache2'
  4. state: 'present'
  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: 'Create basic authentication file for admin (Apache2)'
  65. template:
  66. src: 'apache2/auth_admin.j2'
  67. dest: '/etc/apache2/auth_admin'
  68. owner: 'root'
  69. group: 'www-data'
  70. mode: '0640'
  71. - name: 'Install PHPMyAdmin virtual host for Apache2 (sites-available)'
  72. template:
  73. src: 'apache2/pma_vhost.j2'
  74. dest: '/etc/apache2/sites-available/pma.conf'
  75. owner: 'root'
  76. group: 'root'
  77. mode: '0644'
  78. notify:
  79. - 'Reload apache2'
  80. when: with_phpmyadmin
  81. - name: 'Install PHPMyAdmin virtual host for Apache2 (sites-enabled)'
  82. file:
  83. src: '/etc/apache2/sites-available/pma.conf'
  84. path: '/etc/apache2/sites-enabled/pma.conf'
  85. state: 'link'
  86. notify:
  87. - 'Reload apache2'
  88. when: with_phpmyadmin
  89. - name: "Install PHPPgAdmin virtual host for Apache2 (sites-available)"
  90. template:
  91. src: 'apache2/pga_vhost.j2'
  92. dest: '/etc/apache2/sites-available/pga.conf'
  93. owner: 'root'
  94. group: 'root'
  95. mode: '0644'
  96. notify:
  97. - 'Reload apache2'
  98. when: with_phppgadmin
  99. - name: 'Install PHPPgAdmin virtual host for Apache2 (sites-enabled)'
  100. file:
  101. src: '/etc/apache2/sites-available/pga.conf'
  102. path: '/etc/apache2/sites-enabled/pga.conf'
  103. state: 'link'
  104. notify:
  105. - 'Reload apache2'
  106. when: with_phppgadmin
  107. - name: 'Install PHP system checks virtual host for Apache2 (sites-available)'
  108. template:
  109. src: 'apache2/sys_vhost.j2'
  110. dest: '/etc/apache2/sites-available/sys.conf'
  111. owner: 'root'
  112. group: 'root'
  113. mode: '0644'
  114. notify:
  115. - 'Reload apache2'
  116. when: with_php
  117. - name: 'Install PHP system checks virtual host for Apache2 (sites-enabled)'
  118. file:
  119. src: '/etc/apache2/sites-available/sys.conf'
  120. path: '/etc/apache2/sites-enabled/sys.conf'
  121. state: 'link'
  122. notify:
  123. - 'Reload apache2'
  124. when: with_php
  125. - name: 'Ensure apache2 is running'
  126. service:
  127. name: 'apache2'
  128. state: 'started'