Skip to content

Commit 981954a

Browse files
committed
refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead
Ansible 2.20 has deprecated the use of Ansible facts as variables. For example, `ansible_distribution` is now deprecated in favor of `ansible_facts["distribution"]`. This is due to making the default setting `INJECT_FACTS_AS_VARS=false`. For now, this will create WARNING messages, but in Ansible 2.24 it will be an error. See https://docs.ansible.com/projects/ansible/latest/porting_guides/porting_guide_core_2.20.html#inject-facts-as-vars Signed-off-by: Rich Megginson <rmeggins@redhat.com>
1 parent b3a1c1d commit 981954a

19 files changed

+28
-26
lines changed

.github/workflows/qemu-kvm-integration-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444

4545
env:
4646
TOX_ARGS: "--skip-tags tests::infiniband,tests::nvme,tests::scsi"
47+
ANSIBLE_INJECT_FACT_VARS: "false"
4748

4849
steps:
4950
- name: Checkout repo

.github/workflows/tft.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ jobs:
168168
SR_ARTIFACTS_DIR=${{ steps.set_vars.outputs.ARTIFACTS_DIR }};\
169169
SR_TEST_LOCAL_CHANGES=false;\
170170
SR_LSR_USER=${{ vars.SR_LSR_USER }};\
171+
SR_ANSIBLE_INJECT_FACT_VARS=false;\
171172
SR_ARTIFACTS_URL=${{ steps.set_vars.outputs.ARTIFACTS_URL }}"
172173
# Note that LINUXSYSTEMROLES_SSH_KEY must be single-line, TF doesn't read multi-line variables fine.
173174
secrets: "SR_LSR_DOMAIN=${{ secrets.SR_LSR_DOMAIN }};\

README-ostree.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Usage:
2020
.ostree/get_ostree_data.sh packages runtime DISTRO-VERSION FORMAT
2121
```
2222

23-
`DISTRO-VERSION` is in the format that Ansible uses for `ansible_distribution`
24-
and `ansible_distribution_version` - for example, `Fedora-38`, `CentOS-8`,
23+
`DISTRO-VERSION` is in the format that Ansible uses for `ansible_facts["distribution"]`
24+
and `ansible_facts["distribution_version"]` - for example, `Fedora-38`, `CentOS-8`,
2525
`RedHat-9.4`
2626

2727
`FORMAT` is one of `toml`, `json`, `yaml`, `raw`

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ in /var/lib/pcsd with the file name FILENAME.crt and FILENAME.key, respectively.
17521752
vars:
17531753
ha_cluster_pcsd_certificates:
17541754
- name: FILENAME
1755-
common_name: "{{ ansible_hostname }}"
1755+
common_name: "{{ ansible_facts['hostname'] }}"
17561756
ca: self-sign
17571757
roles:
17581758
- linux-system-roles.ha_cluster

examples/create-pcsd-cert.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
vars:
88
ha_cluster_pcsd_certificates:
99
- name: pcsd_cert
10-
common_name: "{{ ansible_hostname }}"
10+
common_name: "{{ ansible_facts['hostname'] }}"
1111
ca: self-sign
1212
roles:
1313
- linux-system-roles.ha_cluster

tasks/enable-repositories/Suse.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# All cluster packages are present on SLES_SAP and openSUSE,
77
# but not on base SLES without HAE.
88
- name: Block to assert that High Availability Extension is present on SLES
9-
when: ansible_distribution == 'SLES'
9+
when: ansible_facts["distribution"] == 'SLES'
1010
block:
1111

1212
- name: Query package sle-ha-release # noqa command-instead-of-module

tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
cmd: >-
3838
openssl passwd
3939
-6
40-
-salt {{ ansible_hostname.replace('-', 'x') | quote }}
40+
-salt {{ ansible_facts['hostname'].replace('-', 'x') | quote }}
4141
{{ ha_cluster_hacluster_password | string | quote }}
4242
register: __ha_cluster_openssl_call_result
4343
changed_when: false
@@ -74,7 +74,7 @@
7474
ha_cluster_sbd_enabled | ternary(__ha_cluster_sbd_packages, [])
7575
+
7676
ha_cluster_install_cloud_agents |
77-
ternary(__ha_cluster_cloud_agents_packages[ansible_architecture]
77+
ternary(__ha_cluster_cloud_agents_packages[ansible_facts['architecture']]
7878
| d(__ha_cluster_cloud_agents_packages['noarch'] | d([])),
7979
[])
8080
+
@@ -86,7 +86,7 @@
8686
- name: Distribute fence-virt authkey
8787
include_tasks: distribute-fence-virt-key.yml
8888
when:
89-
- ansible_architecture == "x86_64"
89+
- ansible_facts["architecture"] == "x86_64"
9090

9191
- name: Configure SBD
9292
include_tasks: shell_{{ ha_cluster_pacemaker_shell }}/sbd.yml

tasks/shell_crmsh/cluster-auth.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
validate: 'visudo -cf %s'
5555
vars:
5656
__sudoers_path: >-
57-
{% if (ansible_os_family == 'Suse' and
58-
ansible_distribution_major_version | int > 15) %}
57+
{% if (ansible_facts['os_family'] == 'Suse' and
58+
ansible_facts['distribution_major_version'] | int > 15) %}
5959
/usr/etc/sudoers.d
6060
{%- else -%}
6161
/etc/sudoers.d

tasks/shell_crmsh/create-and-push-cib.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# the only thing which matters is pushing the resulting CIB to the cluster.
66

77
# Create backup of current cib in /root
8-
- name: Gather facts for ansible_date_time
8+
- name: Gather facts for ansible_facts["date_time"]
99
ansible.builtin.setup:
1010
filter:
1111
- 'ansible_date_time'

tasks/test_setup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
set_fact:
3434
ha_cluster_enable_repos: false
3535
when:
36-
- ansible_distribution == 'RedHat'
36+
- ansible_facts["distribution"] == 'RedHat'
3737

3838
# HACK - test systems build ostree images with /usr/lib/passwd
3939
# have to copy hacluster user to /etc/passwd

0 commit comments

Comments
 (0)