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>
This commit is contained in:
committed by
Richard Megginson
parent
ebf671b9a8
commit
c9cd2fb359
@@ -30,10 +30,10 @@
|
||||
# create all variants like CentOS, CentOS_8.1, CentOS-8.1,
|
||||
# CentOS-8, CentOS-8.1
|
||||
# more formally:
|
||||
# {{ ansible_distribution }}-{{ ansible_distribution_version }}
|
||||
# {{ ansible_distribution }}-{{ ansible_distribution_major_version }}
|
||||
# {{ ansible_distribution }}
|
||||
# {{ ansible_os_family }}
|
||||
# {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
|
||||
# {{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}
|
||||
# {{ ansible_facts['distribution'] }}
|
||||
# {{ ansible_facts['os_family'] }}
|
||||
# and the same for _ as separator.
|
||||
varfiles: "{{ [facts['distribution']] | product(separators) |
|
||||
map('join') | product(versions) | map('join') | list +
|
||||
|
||||
@@ -14,7 +14,7 @@ __aide_rh_distros:
|
||||
__aide_rh_distros_fedora: "{{ __aide_rh_distros + ['Fedora'] }}"
|
||||
|
||||
# Use this in conditionals to check if distro is Red Hat or clone
|
||||
__aide_is_rh_distro: "{{ ansible_distribution in __aide_rh_distros }}"
|
||||
__aide_is_rh_distro: "{{ ansible_facts['distribution'] in __aide_rh_distros }}"
|
||||
|
||||
# Use this in conditionals to check if distro is Red Hat or clone, or Fedora
|
||||
__aide_is_rh_distro_fedora: "{{ ansible_distribution in __aide_rh_distros_fedora }}"
|
||||
__aide_is_rh_distro_fedora: "{{ ansible_facts['distribution'] in __aide_rh_distros_fedora }}"
|
||||
|
||||
+2
-2
@@ -35,8 +35,8 @@ __aide_rh_distros:
|
||||
__aide_rh_distros_fedora: "{{ __aide_rh_distros + ['Fedora'] }}"
|
||||
|
||||
# Use this in conditionals to check if distro is Red Hat or clone
|
||||
__aide_is_rh_distro: "{{ ansible_distribution in __aide_rh_distros }}"
|
||||
__aide_is_rh_distro: "{{ ansible_facts['distribution'] in __aide_rh_distros }}"
|
||||
|
||||
# Use this in conditionals to check if distro is Red Hat or clone, or Fedora
|
||||
__aide_is_rh_distro_fedora: "{{ ansible_distribution in __aide_rh_distros_fedora }}"
|
||||
__aide_is_rh_distro_fedora: "{{ ansible_facts['distribution'] in __aide_rh_distros_fedora }}"
|
||||
# END - DO NOT EDIT THIS BLOCK - rh distros variables
|
||||
|
||||
Reference in New Issue
Block a user