Skip to content

Commit dc37f14

Browse files
committed
YDA-7297: update legacy fact name format
The legacy fact name format (e.g. "ansible_os_family") will be removed in Ansible v2.24.0. Replace it with the regular bracket format (e.g. ansible_facts["os_family"]) to remain compatible with newer Ansible versions. The fallbacks to the FQDN facts for yoda_fqdn are there so we have a fallback in case the playbook is run with --tags
1 parent b88314d commit dc37f14

71 files changed

Lines changed: 214 additions & 214 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎roles/acme_certificates/defaults/main.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ openssl_o: 'Utrecht University'
1919
openssl_c: 'NL'
2020
openssl_locality_name: 'Utrecht'
2121

22-
certificate_domain: "{{ ansible_fqdn }}"
22+
certificate_domain: "{{ yoda_fqdn | default(ansible_facts['fqdn']) }}"
2323

2424
acme_certificates_email_contact: l.r.westerhof@uu.nl

‎roles/acme_certificates/tasks/main.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# copyright Utrecht University
33

44
- name: Include OS-specific variables
5-
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
5+
ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yml"
66

77

88
- name: Ensure Certbot for Let's Encrypt is installed

‎roles/anubis/tasks/install-redhat.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# copyright Utrecht University
33

44
- name: Include OS-specific variables
5-
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
5+
ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yml"
66

77

88
- name: Download Anubis package

‎roles/anubis/tasks/install-ubuntu.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# copyright Utrecht University
33

44
- name: Include OS-specific variables
5-
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
5+
ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yml"
66

77

88
- name: Download Anubis package

‎roles/anubis/tasks/setup-anubis.yml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
# copyright Utrecht University
33

44
- name: Include OS-specific variables
5-
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
5+
ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yml"
66

77

88
- name: Install Anubis (EL)
99
ansible.builtin.import_tasks: install-redhat.yml
10-
when: ansible_os_family == 'RedHat'
10+
when: ansible_facts['os_family'] == 'RedHat'
1111

1212

1313
- name: Install Anubis (Ubuntu)
1414
ansible.builtin.import_tasks: install-ubuntu.yml
15-
when: ansible_os_family == 'Debian'
15+
when: ansible_facts['os_family'] == 'Debian'
1616

1717

1818
- name: Ensure Anubis env file is present for DavRods
@@ -69,15 +69,15 @@
6969
- "proxy_http"
7070
- "rewrite"
7171
- "substitute"
72-
when: ansible_os_family == 'Debian'
72+
when: ansible_facts['os_family'] == 'Debian'
7373

7474

7575
- name: Allow Anubis to make network connections
7676
ansible.posix.seboolean:
7777
name: httpd_can_network_connect
7878
state: true
7979
persistent: true
80-
when: ansible_os_family == 'RedHat' and ansible_selinux.status == "enabled"
80+
when: ansible_facts['os_family'] == 'RedHat' and ansible_facts['selinux']['status'] == "enabled"
8181

8282

8383
- name: Allow Anubis to listen on ports for DavRods
@@ -89,7 +89,7 @@
8989
notify: Restart Anubis (davrods)
9090
when:
9191
- inventory_hostname in groups.get('portals', []) or inventory_hostname in groups.get('davrods', [])
92-
- ansible_os_family == 'RedHat' and ansible_selinux.status == "enabled"
92+
- ansible_facts['os_family'] == 'RedHat' and ansible_facts['selinux']['status'] == "enabled"
9393
- yoda_davrods_anonymous_enabled is not defined or yoda_davrods_anonymous_enabled
9494

9595

@@ -102,7 +102,7 @@
102102
notify: Restart Anubis (landingpages)
103103
when:
104104
- inventory_hostname in groups.get('publics', [])
105-
- ansible_os_family == 'RedHat' and ansible_selinux.status == "enabled"
105+
- ansible_facts['os_family'] == 'RedHat' and ansible_facts['selinux']['status'] == "enabled"
106106

107107

108108
- name: Ensure Anubis is running and enabled for Davrods

‎roles/apache/tasks/main-tasks.yml‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# copyright Utrecht University
33

44
- name: Include OS-specific variables
5-
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
5+
ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yml"
66

77

88
- name: Ensure Apache webserver is installed
@@ -18,7 +18,7 @@
1818
ansible.builtin.package:
1919
name: mod_ssl
2020
state: present
21-
when: ansible_os_family == 'RedHat'
21+
when: ansible_facts['os_family'] == 'RedHat'
2222

2323

2424
- name: Allow public to ports for Apache in firewall
@@ -55,15 +55,15 @@
5555
dest: /etc/apache2/conf-available/other-vhosts-access-log.conf
5656
mode: '0644'
5757
notify: Restart Apache webserver
58-
when: ansible_os_family == 'Debian'
58+
when: ansible_facts['os_family'] == 'Debian'
5959

6060

6161
- name: Copy Apache ports configuration file (Ubuntu)
6262
ansible.builtin.copy:
6363
src: ports.conf.noble
6464
dest: /etc/apache2/ports.conf
6565
mode: '0600'
66-
when: ansible_os_family == 'Debian'
66+
when: ansible_facts['os_family'] == 'Debian'
6767

6868

6969
- name: Copy Apache security configuration file (Ubuntu)
@@ -74,7 +74,7 @@
7474
group: root
7575
mode: '0644'
7676
notify: Restart Apache webserver
77-
when: ansible_os_family == 'Debian'
77+
when: ansible_facts['os_family'] == 'Debian'
7878

7979

8080
- name: Copy bad bots blocklist
@@ -92,7 +92,7 @@
9292
dest: "/etc/apache2/conf-enabled/bad_bots.conf"
9393
state: link
9494
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
9696

9797

9898
- name: Ensure autoindex.conf is absent
@@ -102,7 +102,7 @@
102102
notify: Restart Apache webserver
103103
with_items:
104104
- /etc/httpd/conf.d/autoindex.conf
105-
when: ansible_os_family == 'RedHat'
105+
when: ansible_facts['os_family'] == 'RedHat'
106106

107107

108108
- name: Ensure unused Apache configurations are removed
@@ -114,7 +114,7 @@
114114
- /etc/httpd/conf.modules.d/00-lua.conf
115115
- /etc/httpd/conf.modules.d/01-cgi.conf
116116
- /etc/httpd/conf.modules.d/15-php.conf
117-
when: ansible_os_family == 'RedHat'
117+
when: ansible_facts['os_family'] == 'RedHat'
118118

119119

120120
- name: Ensure Apache modules used by Yoda are enabled (Ubuntu)
@@ -127,7 +127,7 @@
127127
- headers
128128
- ssl
129129
- socache_shmcb
130-
when: ansible_os_family == 'Debian'
130+
when: ansible_facts['os_family'] == 'Debian'
131131

132132

133133
- name: Ensure Apache global SSL configuration is loaded (Ubuntu)
@@ -136,7 +136,7 @@
136136
dest: "/etc/apache2/mods-enabled/ssl.conf"
137137
state: link
138138
notify: Restart Apache webserver
139-
when: ansible_os_family == 'Debian'
139+
when: ansible_facts['os_family'] == 'Debian'
140140

141141

142142
- name: Configure Apache apparmor profile
@@ -147,7 +147,7 @@
147147
group: root
148148
mode: '0644'
149149
register: apache_apparmor
150-
when: ansible_os_family == 'Debian'
150+
when: ansible_facts['os_family'] == 'Debian'
151151

152152

153153
- name: Put Apache in AppArmor enforce mode
@@ -156,7 +156,7 @@
156156
apparmor_parser -r /etc/apparmor.d/usr.sbin.apache2
157157
notify: Restart Apache webserver
158158
changed_when: true
159-
when: ansible_os_family == 'Debian' and apache_apparmor.changed
159+
when: ansible_facts['os_family'] == 'Debian' and apache_apparmor.changed
160160

161161

162162
- name: Ensure Apache service is configured

‎roles/apache_wsgi/tasks/main-tasks.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
- name: Install Mod-WSGI for Python (Ubuntu)
55
ansible.builtin.apt:
66
name: libapache2-mod-wsgi-py3
7-
when: ansible_os_family == 'Debian'
7+
when: ansible_facts['os_family'] == 'Debian'
88

99

1010
- name: Install Mod-WSGI for Python (EL)
1111
ansible.builtin.pip:
1212
name:
1313
- mod-wsgi==5.0.2
1414
executable: /usr/bin/pip3.12
15-
when: ansible_os_family == 'RedHat'
15+
when: ansible_facts['os_family'] == 'RedHat'
1616

1717

1818
- name: Configure WSGI module in Apache
@@ -23,15 +23,15 @@
2323
group: root
2424
mode: '0644'
2525
notify: Restart Apache webserver
26-
when: ansible_os_family == 'RedHat'
26+
when: ansible_facts['os_family'] == 'RedHat'
2727

2828

2929
- name: Remove old WSGI configurations in Apache
3030
ansible.builtin.file:
3131
path: '{{ item }}'
3232
state: absent
3333
notify: Restart Apache webserver
34-
when: ansible_os_family == 'RedHat'
34+
when: ansible_facts['os_family'] == 'RedHat'
3535
with_items:
3636
- /etc/httpd/conf.modules.d/10-wsgi.conf
3737
- /etc/httpd/conf.modules.d/10-wsgi-python3.conf
@@ -45,7 +45,7 @@
4545
group: root
4646
mode: '0644'
4747
register: python_selinux
48-
when: ansible_os_family == 'RedHat'
48+
when: ansible_facts['os_family'] == 'RedHat'
4949

5050

5151
# Running as task instead of handler in order to prevent ordering issues
@@ -54,4 +54,4 @@
5454
ansible.builtin.command:
5555
cmd: semodule -i /root/my-httpd.pp
5656
changed_when: false
57-
when: ansible_os_family == 'RedHat' and not ansible_check_mode and python_selinux.changed
57+
when: ansible_facts['os_family'] == 'RedHat' and not ansible_check_mode and python_selinux.changed

‎roles/certificates/defaults/main.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ openssl_o: 'Utrecht University'
1717
openssl_c: 'NL'
1818
openssl_locality_name: 'Utrecht'
1919

20-
certificate_domain: "{{ ansible_fqdn }}"
20+
certificate_domain: "{{ yoda_fqdn | default(ansible_facts['fqdn']) }}"

‎roles/certificates/tasks/main-tasks.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# copyright Utrecht University
33

44
- name: Include OS-specific variables
5-
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
5+
ansible.builtin.include_vars: "{{ ansible_facts['os_family'] }}.yml"
66

77

88
- name: Ensure dependencies for Ansible OpenSSL module are present

‎roles/common/tasks/basics-redhat.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
- python3-policycoreutils
1010
- python3-dnf-plugin-versionlock
1111
state: present
12-
when: ansible_distribution_major_version == "9"
12+
when: ansible_facts['distribution_major_version'] == "9"
1313

1414

1515
- name: Ensure basics (vim, bind-utils, etc.) are installed

0 commit comments

Comments
 (0)