|
2 | 2 | # copyright Utrecht University |
3 | 3 |
|
4 | 4 | - name: Include OS-specific variables |
5 | | - ansible.builtin.include_vars: "{{ ansible_os_family }}.yml" |
| 5 | + ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yml" |
6 | 6 |
|
7 | 7 |
|
8 | 8 | - name: Ensure Apache webserver is installed |
|
18 | 18 | ansible.builtin.package: |
19 | 19 | name: mod_ssl |
20 | 20 | state: present |
21 | | - when: ansible_os_family == 'RedHat' |
| 21 | + when: ansible_facts['os_family'] == 'RedHat' |
22 | 22 |
|
23 | 23 |
|
24 | 24 | - name: Allow public to ports for Apache in firewall |
|
55 | 55 | dest: /etc/apache2/conf-available/other-vhosts-access-log.conf |
56 | 56 | mode: '0644' |
57 | 57 | notify: Restart Apache webserver |
58 | | - when: ansible_os_family == 'Debian' |
| 58 | + when: ansible_facts['os_family'] == 'Debian' |
59 | 59 |
|
60 | 60 |
|
61 | 61 | - name: Copy Apache ports configuration file (Ubuntu) |
62 | 62 | ansible.builtin.copy: |
63 | 63 | src: ports.conf.noble |
64 | 64 | dest: /etc/apache2/ports.conf |
65 | 65 | mode: '0600' |
66 | | - when: ansible_os_family == 'Debian' |
| 66 | + when: ansible_facts['os_family'] == 'Debian' |
67 | 67 |
|
68 | 68 |
|
69 | 69 | - name: Copy Apache security configuration file (Ubuntu) |
|
74 | 74 | group: root |
75 | 75 | mode: '0644' |
76 | 76 | notify: Restart Apache webserver |
77 | | - when: ansible_os_family == 'Debian' |
| 77 | + when: ansible_facts['os_family'] == 'Debian' |
78 | 78 |
|
79 | 79 |
|
80 | 80 | - name: Copy bad bots blocklist |
|
92 | 92 | dest: "/etc/apache2/conf-enabled/bad_bots.conf" |
93 | 93 | state: link |
94 | 94 | notify: Restart Apache webserver |
95 | | - when: ansible_os_family == 'Debian' and not ansible_check_mode |
| 95 | + when: ansible_facts['os_family'] == 'Debian' and not ansible_check_mode |
96 | 96 |
|
97 | 97 |
|
98 | 98 | - name: Ensure autoindex.conf is absent |
|
102 | 102 | notify: Restart Apache webserver |
103 | 103 | with_items: |
104 | 104 | - /etc/httpd/conf.d/autoindex.conf |
105 | | - when: ansible_os_family == 'RedHat' |
| 105 | + when: ansible_facts['os_family'] == 'RedHat' |
106 | 106 |
|
107 | 107 |
|
108 | 108 | - name: Ensure unused Apache configurations are removed |
|
114 | 114 | - /etc/httpd/conf.modules.d/00-lua.conf |
115 | 115 | - /etc/httpd/conf.modules.d/01-cgi.conf |
116 | 116 | - /etc/httpd/conf.modules.d/15-php.conf |
117 | | - when: ansible_os_family == 'RedHat' |
| 117 | + when: ansible_facts['os_family'] == 'RedHat' |
118 | 118 |
|
119 | 119 |
|
120 | 120 | - name: Ensure Apache modules used by Yoda are enabled (Ubuntu) |
|
127 | 127 | - headers |
128 | 128 | - ssl |
129 | 129 | - socache_shmcb |
130 | | - when: ansible_os_family == 'Debian' |
| 130 | + when: ansible_facts['os_family'] == 'Debian' |
131 | 131 |
|
132 | 132 |
|
133 | 133 | - name: Ensure Apache global SSL configuration is loaded (Ubuntu) |
|
136 | 136 | dest: "/etc/apache2/mods-enabled/ssl.conf" |
137 | 137 | state: link |
138 | 138 | notify: Restart Apache webserver |
139 | | - when: ansible_os_family == 'Debian' |
| 139 | + when: ansible_facts['os_family'] == 'Debian' |
140 | 140 |
|
141 | 141 |
|
142 | 142 | - name: Configure Apache apparmor profile |
|
147 | 147 | group: root |
148 | 148 | mode: '0644' |
149 | 149 | register: apache_apparmor |
150 | | - when: ansible_os_family == 'Debian' |
| 150 | + when: ansible_facts['os_family'] == 'Debian' |
151 | 151 |
|
152 | 152 |
|
153 | 153 | - name: Put Apache in AppArmor enforce mode |
|
156 | 156 | apparmor_parser -r /etc/apparmor.d/usr.sbin.apache2 |
157 | 157 | notify: Restart Apache webserver |
158 | 158 | changed_when: true |
159 | | - when: ansible_os_family == 'Debian' and apache_apparmor.changed |
| 159 | + when: ansible_facts['os_family'] == 'Debian' and apache_apparmor.changed |
160 | 160 |
|
161 | 161 |
|
162 | 162 | - name: Ensure Apache service is configured |
|
0 commit comments