source: darkpeak-services/roles/apache2/tasks/main.yml @ 1d1868f0

Last change on this file since 1d1868f0 was 1d1868f0, checked in by Mat Booth <mbooth@…>, 10 months ago

Fix #66 - Add logrotate config for the application-specific apache logs

  • Property mode set to 100644
File size: 2.1 KB
Line 
1- name: Install web server packages
2  apt:
3    name: "{{ item }}"
4    state: present
5    update_cache: yes
6    cache_valid_time: 10800   # 3 hours
7  with_items:
8    - apache2
9    - libapache2-mod-php7.3
10  notify:
11    - reload apache2
12
13- name: Create directory for custom site config
14  file:
15    state: directory
16    path:  /etc/apache2/includes
17    group: root
18    owner: root
19    mode:  0755
20
21- name: Disable and remove default vhost
22  file:
23    path: "{{ item }}"
24    state: absent
25  with_items:
26    - /etc/apache2/sites-enabled/000-default.conf
27    - /etc/apache2/sites-available/000-default.conf
28    - /etc/apache2/sites-available/default-ssl.conf
29    - /var/www/html
30  notify:
31    - reload apache2
32
33- name: Install main apache configuration
34  copy:
35    src: "{{ item.src }}.conf"
36    dest: "/etc/apache2/{{ item.dest }}.conf"
37    group: root
38    owner: root
39    mode: 0644
40  with_items:
41    - { src: apache2, dest: apache2 }
42    - { src: mods/dir, dest: mods-available/dir }
43    - { src: mods/headers, dest: mods-available/headers }
44    - { src: mods/include, dest: mods-available/include }
45    - { src: mods/mime, dest: mods-available/mime }
46    - { src: mods/ssl, dest: mods-available/ssl }
47  notify:
48    - reload apache2
49
50- name: Enable standard apache modules
51  apache2_module:
52    name: "{{ item }}"
53    state: present
54    force: yes
55  with_items:
56    - autoindex
57    - deflate
58    - dir
59    - headers
60    - include
61    - mime
62    - proxy_http
63    - ssl
64    - rewrite
65    - php7.3
66  notify:
67    - reload apache2
68
69- name: Install logrotate configuration for apache
70  copy:
71    src: logrotate_config
72    dest: /etc/logrotate.d/apache2
73    group: root
74    owner: root
75    mode: 0644
76
77- name: Configure apache for default site
78  include: configure-apache-site.yml
79
80- name: Install placeholder index for default site
81  copy:
82    src: index.html
83    dest: "{{ web_root }}/index.html"
84    group: www-data
85    owner: root
86    mode: 0640
87
88- name: TODO - Add users to the www-data group instead of setting 777 here
89  file:
90    state: directory
91    path:  "{{ web_root }}"
92    group: www-data
93    owner: root
94    mode:  0777
Note: See TracBrowser for help on using the repository browser.