Integration tests: replace ansible_xxx with ansible_facts.xxx (#11479)

Replace ansible_xxx with ansible_facts.xxx.
This commit is contained in:
Felix Fontein
2026-02-07 18:18:48 +01:00
committed by GitHub
parent 106817316d
commit 476f2bf641
144 changed files with 548 additions and 578 deletions

View File

@@ -23,12 +23,12 @@
- name: set config file path on Debian
set_fact:
timezone_config_file: '/etc/timezone'
when: ansible_os_family == 'Debian'
when: ansible_facts.os_family == 'Debian'
- name: set config file path on RedHat
set_fact:
timezone_config_file: '/etc/sysconfig/clock'
when: ansible_os_family == 'RedHat'
when: ansible_facts.os_family == 'RedHat'
##
## set path to hwclock config files
@@ -37,12 +37,12 @@
- name: set config file path on Debian
set_fact:
hwclock_config_file: '/etc/default/rcS'
when: ansible_os_family == 'Debian'
when: ansible_facts.os_family == 'Debian'
- name: set config file path on RedHat
set_fact:
hwclock_config_file: '/etc/sysconfig/clock'
when: ansible_os_family == 'RedHat'
when: ansible_facts.os_family == 'RedHat'
####
#### timezone tests
@@ -52,33 +52,33 @@
package:
name: diffutils
state: present
when: ansible_distribution == 'Archlinux'
when: ansible_facts.distribution == 'Archlinux'
- name: make sure util-linux-extra are installed on Debian 13+
package:
name: util-linux-extra
state: present
when: ansible_distribution == 'Debian' and ansible_distribution_major_version|int >= 13
when: ansible_facts.distribution == 'Debian' and ansible_facts.distribution_major_version|int >= 13
- name: make sure tzdata is installed on Alpine
package:
name: tzdata
state: present
when: ansible_distribution == 'Alpine'
when: ansible_facts.distribution == 'Alpine'
- name: make sure hwclock is installed in Ubuntu 24.04
package:
name: util-linux-extra
state: present
when:
- ansible_distribution == 'Ubuntu'
- ansible_facts.distribution == 'Ubuntu'
- ansible_facts.distribution_major_version is version('24', '>=')
- name: Run tests
when:
- not (ansible_os_family == 'Alpine') # TODO
- not (ansible_distribution == 'Archlinux') # TODO
- not (ansible_facts.os_family == 'Alpine') # TODO
- not (ansible_facts.distribution == 'Archlinux') # TODO
block:
- name: set timezone to Etc/UTC
timezone:

View File

@@ -29,14 +29,14 @@
- name: ensure that checkmode didn't update the timezone in the config file
command: egrep '^(TIME)?ZONE="Etc/UTC"' {{ timezone_config_file }}
when:
- ansible_service_mgr != 'systemd'
- ansible_os_family == 'RedHat'
- ansible_facts.service_mgr != 'systemd'
- ansible_facts.os_family == 'RedHat'
- name: ensure that checkmode didn't update the timezone in the config file
command: egrep '^Etc/UTC' {{ timezone_config_file }}
when:
- ansible_service_mgr != 'systemd'
- ansible_os_family == 'Debian'
- ansible_facts.service_mgr != 'systemd'
- ansible_facts.os_family == 'Debian'
- name: set timezone to Australia/Brisbane
timezone:
@@ -57,14 +57,14 @@
- name: ensure that the timezone is updated in the config file
command: egrep '^(TIME)?ZONE="Australia/Brisbane"' {{ timezone_config_file }}
when:
- ansible_service_mgr != 'systemd'
- ansible_os_family == 'RedHat'
- ansible_facts.service_mgr != 'systemd'
- ansible_facts.os_family == 'RedHat'
- name: ensure that the timezone is updated in the config file
command: egrep '^Australia/Brisbane' {{ timezone_config_file }}
when:
- ansible_service_mgr != 'systemd'
- ansible_os_family == 'Debian'
- ansible_facts.service_mgr != 'systemd'
- ansible_facts.os_family == 'Debian'
- name: set timezone to Australia/Brisbane again
timezone:
@@ -272,7 +272,7 @@
command: cmp /etc/localtime /usr/share/zoneinfo/Europe/Belgrade
changed_when: false
when:
- ansible_service_mgr != 'systemd'
- ansible_facts.service_mgr != 'systemd'
- timezone_config_file is defined
@@ -323,7 +323,7 @@
- name: ensure that checkmode didn't update hwclock the config file
command: grep ^UTC=no {{ hwclock_config_file }}
when: ansible_service_mgr != 'systemd'
when: ansible_facts.service_mgr != 'systemd'
- name: set hwclock to UTC
timezone:
@@ -343,7 +343,7 @@
- name: ensure that hwclock is updated in the config file
command: grep ^UTC=yes {{ hwclock_config_file }}
when: ansible_service_mgr != 'systemd'
when: ansible_facts.service_mgr != 'systemd'
- name: set hwclock to RTC again
timezone:
@@ -490,7 +490,7 @@
- hwclock_set_local_broken_adjtime.diff.after.hwclock == 'local'
- hwclock_set_local_broken_adjtime.diff.before.hwclock == 'UTC'
when:
- ansible_service_mgr != 'systemd'
- ansible_facts.service_mgr != 'systemd'
- hwclock_config_file is defined
####
@@ -532,12 +532,12 @@
- name: ensure that checkmode didn't update the timezone in the config file
command: egrep '^(TIME)?ZONE="Etc/UTC"' {{ timezone_config_file }}
when:
- ansible_os_family == 'RedHat'
- ansible_facts.os_family == 'RedHat'
- name: ensure that checkmode didn't update the timezone in the config file
command: egrep '^Etc/UTC' {{ timezone_config_file }}
when:
- ansible_os_family == 'Debian'
- ansible_facts.os_family == 'Debian'
- name: ensure that checkmode didn't update hwclock in /etc/adjtime
command: grep ^UTC /etc/adjtime
@@ -546,7 +546,7 @@
- name: ensure that checkmode didn't update hwclock the config file
command: grep ^UTC=no {{ hwclock_config_file }}
when: ansible_service_mgr != 'systemd'
when: ansible_facts.service_mgr != 'systemd'
- name: set timezone to Europe/Belgrade and hwclock to UTC
timezone:
@@ -571,19 +571,19 @@
- name: ensure that the timezone is updated in the config file
command: egrep '^(TIME)?ZONE="Europe/Belgrade"' {{ timezone_config_file }}
when:
- ansible_os_family == 'RedHat'
- ansible_facts.os_family == 'RedHat'
- name: ensure that the timezone is updated in the config file
command: egrep 'Europe/Belgrade' {{ timezone_config_file }}
when:
- ansible_os_family == 'Debian'
- ansible_facts.os_family == 'Debian'
- name: ensure that hwclock is updated in /etc/adjtime
command: grep ^UTC /etc/adjtime
- name: ensure that hwclock is updated in the config file
command: grep ^UTC=yes {{ hwclock_config_file }}
when: ansible_service_mgr != 'systemd'
when: ansible_facts.service_mgr != 'systemd'
- name: set timezone to Europe/Belgrade and hwclock to UTC again
timezone:
@@ -608,5 +608,5 @@
- not tzclock_set_again_checkmode.changed
when:
- ansible_system == 'Linux'
- ansible_facts.system == 'Linux'
- hwclock_supported