Use ansible_facts[] instead of fact variables in tests

See https://github.com/ansible/ansible/issues/73654

Change-Id: I7e27477d4fb1292aa5d79adcf6cb33eaa31da035
This commit is contained in:
Jonathan Rosser 2021-03-01 13:25:13 +00:00
parent 6c94ac8515
commit e2c4cd43bb
11 changed files with 37 additions and 36 deletions

View File

@ -60,7 +60,7 @@
PrintLastLog: no PrintLastLog: no
TCPKeepAlive: yes TCPKeepAlive: yes
AcceptEnv: "LANG LC_*" AcceptEnv: "LANG LC_*"
Subsystem: "{{ sftp_subsystem[ansible_pkg_mgr] }}" Subsystem: "{{ sftp_subsystem[ansible_facts['pkg_mgr']] }}"
UsePAM: yes UsePAM: yes
UseDNS: no UseDNS: no
X11Forwarding: no X11Forwarding: no
@ -81,8 +81,10 @@
- name: Check that new network interfaces are up - name: Check that new network interfaces are up
assert: assert:
that: that:
- ansible_eth12['active'] | bool - ansible_facts['eth12']['active'] | bool
- ansible_eth13['active'] | bool - ansible_facts['eth13']['active'] | bool
- ansible_eth14['active'] | bool - ansible_facts['eth14']['active'] | bool
when: when:
- (bootstrap_host_container_tech | default('unknown')) != 'nspawn' - (bootstrap_host_container_tech | default('unknown')) != 'nspawn'
- name: Clear facts
meta: clear_facts

View File

@ -105,7 +105,7 @@ vlan_range: "172.29.248"
netmask: "255.255.252.0" netmask: "255.255.252.0"
# #
# NICs # NICs
bootstrap_host_public_interface: "{{ ansible_default_ipv4.interface }}" bootstrap_host_public_interface: "{{ ansible_facts['default_ipv4']['interface'] }}"
# #
# Utility paths # Utility paths
bootstrap_host_network_utils: bootstrap_host_network_utils:
@ -126,9 +126,9 @@ bootstrap_host_network_utils:
ethtool: /sbin/ethtool ethtool: /sbin/ethtool
ip: /sbin/ip ip: /sbin/ip
# #
bootstrap_host_iptables_path: "{{ bootstrap_host_network_utils[ansible_pkg_mgr]['iptables'] }}" bootstrap_host_iptables_path: "{{ bootstrap_host_network_utils[ansible_facts['pkg_mgr']]['iptables'] }}"
bootstrap_host_ethtool_path: "{{ bootstrap_host_network_utils[ansible_pkg_mgr]['ethtool'] }}" bootstrap_host_ethtool_path: "{{ bootstrap_host_network_utils[ansible_facts['pkg_mgr']]['ethtool'] }}"
bootstrap_host_ip_path: "{{ bootstrap_host_network_utils[ansible_pkg_mgr]['ip'] }}" bootstrap_host_ip_path: "{{ bootstrap_host_network_utils[ansible_facts['pkg_mgr']]['ip'] }}"
## Extra storage ## Extra storage
# An AIO may optionally be built using a second storage device. If a # An AIO may optionally be built using a second storage device. If a
@ -179,9 +179,9 @@ bootstrap_host_format_options:
# #
# Set the data disk mount options. # Set the data disk mount options.
bootstrap_host_data_mount_options: bootstrap_host_data_mount_options:
machinectl: "noatime,nodiratime,compress=lzo,commit=120,{{ (ansible_kernel is version('4.5', '>=')) | ternary('space_cache=v2', 'space_cache') }}" machinectl: "noatime,nodiratime,compress=lzo,commit=120,{{ (ansible_facts['kernel'] is version('4.5', '>=')) | ternary('space_cache=v2', 'space_cache') }}"
zfs: "defaults" zfs: "defaults"
btrfs: "noatime,nodiratime,compress=lzo,commit=120,{{ (ansible_kernel is version('4.5', '>=')) | ternary('space_cache=v2', 'space_cache') }}" btrfs: "noatime,nodiratime,compress=lzo,commit=120,{{ (ansible_facts['kernel'] is version('4.5', '>=')) | ternary('space_cache=v2', 'space_cache') }}"
xfs: "noatime,nodiratime,logbufs=8,logbsize=256k" xfs: "noatime,nodiratime,logbufs=8,logbsize=256k"
ext4: "noatime,nobh,barrier=0,data=writeback" ext4: "noatime,nobh,barrier=0,data=writeback"
dir: "defaults" dir: "defaults"

View File

@ -16,12 +16,10 @@
- name: Check for a supported Operating System - name: Check for a supported Operating System
assert: assert:
that: that:
- (ansible_distribution == 'Debian' and ansible_distribution_release == 'stretch') or (ansible_facts['distribution'] == 'Debian' and ansible_facts['distribution_release'] == 'buster') or
(ansible_distribution == 'Debian' and ansible_distribution_release == 'buster') or (ansible_facts['distribution'] == 'Ubuntu' and ansible_facts['distribution_release'] == 'bionic') or
(ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'bionic') or (ansible_facts['distribution'] == 'Ubuntu' and ansible_facts['distribution_release'] == 'focal') or
(ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'focal') or (ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '8')
(ansible_os_family == 'RedHat' and ansible_distribution_major_version == '8') or
(ansible_os_family == 'Suse' and ansible_distribution_major_version in ['42', '15'])
msg: >- msg: >-
The only supported platforms for this release are Debian Stretch, Ubuntu 18.04 LTS (Bionic), The only supported platforms for this release are Debian Stretch, Ubuntu 18.04 LTS (Bionic),
Centos 8, openSUSE Leap 42.X and openSUSE Leap 15.X Centos 8, openSUSE Leap 42.X and openSUSE Leap 15.X
@ -82,14 +80,15 @@
Can not find disk {{ bootstrap_host_data_disk_device }} Can not find disk {{ bootstrap_host_data_disk_device }}
when: when:
- bootstrap_host_data_disk_device != None - bootstrap_host_data_disk_device != None
- ansible_devices.get(bootstrap_host_data_disk_device) == None - ansible_facts['devices'] is defined
- ansible_facts['devices'].get(bootstrap_host_data_disk_device) == None
tags: tags:
- check-disk-size - check-disk-size
- name: Set data disk facts - name: Set data disk facts
set_fact: set_fact:
host_data_disk_sectors: "{{ (ansible_devices[bootstrap_host_data_disk_device]['sectors'] | int) }}" host_data_disk_sectors: "{{ (ansible_facts['devices'][bootstrap_host_data_disk_device]['sectors'] | int) }}"
host_data_disk_sectorsize: "{{ (ansible_devices[bootstrap_host_data_disk_device]['sectorsize'] | int) }}" host_data_disk_sectorsize: "{{ (ansible_facts['devices'][bootstrap_host_data_disk_device]['sectorsize'] | int) }}"
when: when:
- bootstrap_host_data_disk_device != None - bootstrap_host_data_disk_device != None
tags: tags:

View File

@ -24,7 +24,7 @@
package: package:
name: "{{ packages_install }}" name: "{{ packages_install }}"
state: present state: present
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}" update_cache: "{{ (ansible_facts['pkg_mgr'] in ['apt', 'zypper']) | ternary('yes', omit) }}"
tags: tags:
- install-packages - install-packages

View File

@ -29,11 +29,11 @@
- name: Gather variables for each operating system - name: Gather variables for each operating system
include_vars: "{{ item }}" include_vars: "{{ item }}"
with_first_found: with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml" - "{{ ansible_facts['distribution'] | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml" - "{{ ansible_facts['os_family'] | lower }}.yml"
tags: tags:
- always - always
@ -76,7 +76,7 @@
static: no static: no
when: when:
- bootstrap_host_loopback_swap | bool - bootstrap_host_loopback_swap | bool
- ansible_swaptotal_mb < 1 - ansible_facts['swaptotal_mb'] < 1
tags: tags:
- prepare-loopback - prepare-loopback

View File

@ -88,7 +88,7 @@
ceph_apt_repos: ceph_apt_repos:
ceph: ceph:
state: "present" state: "present"
repo: "deb http://{{ nodepool_vars.NODEPOOL_MIRROR_HOST }}/ceph-deb-octopus {{ ansible_distribution_release }} main" repo: "deb http://{{ nodepool_vars.NODEPOOL_MIRROR_HOST }}/ceph-deb-octopus {{ ansible_facts['distribution_release'] }} main"
copy: copy:
dest: /etc/openstack_deploy/user_openstackci.yml dest: /etc/openstack_deploy/user_openstackci.yml
content: "{{ nodepool_overrides | to_nice_yaml }}" content: "{{ nodepool_overrides | to_nice_yaml }}"
@ -118,13 +118,13 @@
policy: targeted policy: targeted
state: permissive state: permissive
when: when:
- ansible_selinux.status == "enabled" - ansible_facts['selinux']['status'] == "enabled"
- name: Get systemd version - name: Get systemd version
command: "rpm -q systemd" command: "rpm -q systemd"
changed_when: false changed_when: false
register: systemd_version register: systemd_version
when: ansible_os_family | lower == 'redhat' when: ansible_facts['os_family'] | lower == 'redhat'
- name: Set the user_variables - name: Set the user_variables
config_template: config_template:

View File

@ -47,7 +47,7 @@
- bootstrap_host_data_disk_device_force | bool - bootstrap_host_data_disk_device_force | bool
- item.device is search(bootstrap_host_data_disk_device) - item.device is search(bootstrap_host_data_disk_device)
with_items: with_items:
- "{{ ansible_mounts }}" - "{{ ansible_facts['mounts'] }}"
- name: Partition the whole data disk for our usage - name: Partition the whole data disk for our usage
command: "{{ item }}" command: "{{ item }}"

View File

@ -17,7 +17,7 @@
package: package:
name: "{{ packages_install_zfs }}" name: "{{ packages_install_zfs }}"
state: present state: present
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}" update_cache: "{{ (ansible_facts['pkg_mgr'] in ['apt', 'zypper']) | ternary('yes', omit) }}"
tags: tags:
- install-packages - install-packages

View File

@ -20,7 +20,7 @@
failed_when: firewalld_check.rc > 1 failed_when: firewalld_check.rc > 1
args: args:
warn: false warn: false
when: ansible_os_family == 'RedHat' when: ansible_facts['os_family'] == 'RedHat'
- name: Disable firewalld - name: Disable firewalld
become: True become: True
@ -31,7 +31,7 @@
with_items: with_items:
- firewalld - firewalld
when: when:
- ansible_os_family == 'RedHat' - ansible_facts['os_family'] == 'RedHat'
- firewalld_check.rc == 0 - firewalld_check.rc == 0
- name: Run the systemd-networkd role - name: Run the systemd-networkd role

View File

@ -17,7 +17,7 @@
package: package:
name: squid name: squid
state: present state: present
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}" update_cache: "{{ (ansible_facts['pkg_mgr'] in ['apt', 'zypper']) | ternary('yes', omit) }}"
notify: Restart squid notify: Restart squid
tags: tags:
- install-packages - install-packages

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
{% if ansible_os_family | lower == 'redhat' %} {% if ansible_facts['os_family'] | lower == 'redhat' %}
deployment_environment_variables: deployment_environment_variables:
LIBSYSTEMD_VERSION: {{ systemd_version.stdout_lines[0].split('-')[1] }} LIBSYSTEMD_VERSION: {{ systemd_version.stdout_lines[0].split('-')[1] }}
{% endif %} {% endif %}
@ -285,7 +285,7 @@ tempest_run_concurrency: 0
deployment_environment_variables: deployment_environment_variables:
http_proxy: http://172.29.236.100:3128/ http_proxy: http://172.29.236.100:3128/
https_proxy: http://172.29.236.100:3128/ https_proxy: http://172.29.236.100:3128/
no_proxy: "localhost,127.0.0.1,172.29.236.100,{{ bootstrap_host_public_address | default(ansible_default_ipv4.address) }}" no_proxy: "localhost,127.0.0.1,172.29.236.100,{{ bootstrap_host_public_address | default(ansible_facts['default_ipv4']['address']) }}"
# Remove eth0 from all container so there is no default route and everything # Remove eth0 from all container so there is no default route and everything
# must go via the http proxy # must go via the http proxy