From 6c94ac8515555d0bea934f60c70363df957e3f64 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 1 Mar 2021 13:23:43 +0000 Subject: [PATCH] Use ansible_facts[] instead of fact variables in group_vars See https://github.com/ansible/ansible/issues/73654 Change-Id: I06ab9cee6539762d7ba3e25e07b5661a8fa485f3 --- inventory/group_vars/all/all.yml | 12 ++++++------ inventory/group_vars/all/ceph.yml | 2 +- inventory/group_vars/all_containers.yml | 2 +- inventory/group_vars/ceph_all.yml | 2 +- inventory/group_vars/haproxy/keepalived.yml | 2 +- inventory/group_vars/hosts.yml | 2 +- inventory/group_vars/neutron_calico_dhcp_agent.yml | 10 +++++----- inventory/group_vars/nova_all.yml | 2 +- inventory/group_vars/utility_all.yml | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/inventory/group_vars/all/all.yml b/inventory/group_vars/all/all.yml index e9fe383921..5801bc0f54 100644 --- a/inventory/group_vars/all/all.yml +++ b/inventory/group_vars/all/all.yml @@ -41,16 +41,16 @@ openstack_service_bind_address: "{{ management_address }}" # Options are 'present' and 'latest'. # NOTE(mhayden): Allowing CentOS and openSUSE to use package_state=present should give # gate jobs a better chance to finish and expose more issues to fix. -package_state: "{{ (ansible_pkg_mgr in ['dnf', 'zypper']) | ternary('present', 'latest') }}" +package_state: "{{ (ansible_facts['pkg_mgr'] in ['dnf', 'zypper']) | ternary('present', 'latest') }}" # Set "/var/log" to be a bind mount to the physical host. default_bind_mount_logs: true # Set distro variable -# NOTE(hwoarang): ansible_distribution may return a string with spaces +# NOTE(hwoarang): ansible_facts['distribution'] may return a string with spaces # such as "openSUSE Leap" so we need to replace the space with underscore # in order to create a more sensible repo name for the distro. -os_distro_version: "{{ (ansible_distribution | lower) | replace(' ', '_') }}-{{ ansible_distribution_version.split('.')[:2] | join('.') }}-{{ ansible_architecture | lower }}" +os_distro_version: "{{ (ansible_facts['distribution'] | lower) | replace(' ', '_') }}-{{ ansible_facts['distribution_version'].split('.')[:2] | join('.') }}-{{ ansible_facts['architecture'] | lower }}" # Set the systemd prefix based on the base OS. systemd_utils_distro_prefix: @@ -59,15 +59,15 @@ systemd_utils_distro_prefix: dnf: "/lib/systemd" zypper: "/usr/lib/systemd" -systemd_utils_prefix: "{{ systemd_utils_distro_prefix[ansible_pkg_mgr] }}" +systemd_utils_prefix: "{{ systemd_utils_distro_prefix[ansible_facts['pkg_mgr']] }}" # Ensure that the package state matches the global setting rsyslog_client_package_state: "{{ package_state }}" # At this time there's no suitable package available for systemd-journal-remote/gateway # When installing on SUSE 42.x. For now this playbook will omit suse when the package # manager is "zypper". When a suitable package is available on SUSE this should be removed. -rsyslog_client_enabled: "{{ ansible_pkg_mgr == 'zypper' }}" -rsyslog_server_enabled: "{{ ansible_pkg_mgr == 'zypper' }}" +rsyslog_client_enabled: "{{ ansible_facts['pkg_mgr'] == 'zypper' }}" +rsyslog_server_enabled: "{{ ansible_facts['pkg_mgr'] == 'zypper' }}" # URL for the frozen internal openstack repo. repo_server_port: 8181 diff --git a/inventory/group_vars/all/ceph.yml b/inventory/group_vars/all/ceph.yml index f274bfba96..d1f8f6d1be 100644 --- a/inventory/group_vars/all/ceph.yml +++ b/inventory/group_vars/all/ceph.yml @@ -22,7 +22,7 @@ osd_group_name: ceph-osd rgw_group_name: ceph-rgw mds_group_name: ceph-mds nfs_group_name: ceph-nfs -ceph_origin: "{{ (ansible_pkg_mgr == 'zypper') | ternary('distro', 'repository') }}" +ceph_origin: "{{ (ansible_facts['pkg_mgr'] == 'zypper') | ternary('distro', 'repository') }}" ceph_repository: community # The _stable_release var is used by both the OSA ceph_client role and the # ceph-ansible roles. It is defaulted in ceph_client but set here to keep the diff --git a/inventory/group_vars/all_containers.yml b/inventory/group_vars/all_containers.yml index c2ff6cc263..a63382db61 100644 --- a/inventory/group_vars/all_containers.yml +++ b/inventory/group_vars/all_containers.yml @@ -16,7 +16,7 @@ # This is the default LXC AppArmor profile # Groups which need the unbound profile have a specific override lxc_container_config_list: - - "lxc.apparmor.profile={{ (hostvars[physical_host]['ansible_distribution'] == 'Debian' and hostvars[physical_host]['ansible_distribution_major_version'] == '10' ) | ternary('unconfined', 'lxc-openstack') }}" + - "lxc.apparmor.profile={{ (hostvars[physical_host]['ansible_facts']['distribution'] == 'Debian' and hostvars[physical_host]['ansible_facts']['distribution_major_version'] == '10' ) | ternary('unconfined', 'lxc-openstack') }}" # Needed by playbooks/common-tasks/os-lxc-container-setup.yml lxc_container_log_path: "/var/log/lxc" diff --git a/inventory/group_vars/ceph_all.yml b/inventory/group_vars/ceph_all.yml index 5742441320..c91cf87884 100644 --- a/inventory/group_vars/ceph_all.yml +++ b/inventory/group_vars/ceph_all.yml @@ -38,7 +38,7 @@ ceph_conf_overrides: "{{ (ceph_conf_overrides_rgw | default({})) | combine(ceph_ # needed. nfs_file_gw: "{{ (('ceph-nfs' in groups) and ('ceph-mds' in groups)) }}" nfs_obj_gw: False -nfs_ganesha_stable: "{{ (ansible_distribution_release not in ['bionic', 'focal']) }}" +nfs_ganesha_stable: "{{ (ansible_facts['distribution_release'] not in ['bionic', 'focal']) }}" # NTP in an OSA environment is handled by ansible-hardening using chrony # ceph-ansible's default enabling of ntpd conflicts with the OSA defaults diff --git a/inventory/group_vars/haproxy/keepalived.yml b/inventory/group_vars/haproxy/keepalived.yml index 07cb05bac6..697e914b04 100644 --- a/inventory/group_vars/haproxy/keepalived.yml +++ b/inventory/group_vars/haproxy/keepalived.yml @@ -16,7 +16,7 @@ keepalived_ping_count: 1 keepalived_ping_interval: 10 keepalived_ubuntu_src: "native" -keepalived_ping_address: "{{ ansible_default_ipv4['gateway'] | default('127.0.0.1') }}" +keepalived_ping_address: "{{ ansible_facts['default_ipv4']['gateway'] | default('127.0.0.1') }}" keepalived_sync_groups: haproxy: diff --git a/inventory/group_vars/hosts.yml b/inventory/group_vars/hosts.yml index 45f88914f4..9a7f143b39 100644 --- a/inventory/group_vars/hosts.yml +++ b/inventory/group_vars/hosts.yml @@ -23,7 +23,7 @@ stig_version: rhel7 # Temporarily avoid putting SELinux into enforcing mode on CentOS until some # additional policy is written. See LP Bug 1657517 for more details. -security_rhel7_enable_linux_security_module: "{{ ansible_os_family == 'RedHat' | ternary(false, true) }}" +security_rhel7_enable_linux_security_module: "{{ (ansible_facts['os_family'] == 'RedHat') | ternary(false, true) }}" # All our ansible tasks run as root user, we need to allow direct root login security_sshd_permit_root_login: 'without-password' diff --git a/inventory/group_vars/neutron_calico_dhcp_agent.yml b/inventory/group_vars/neutron_calico_dhcp_agent.yml index 48fa6ff2ad..c390ec616f 100644 --- a/inventory/group_vars/neutron_calico_dhcp_agent.yml +++ b/inventory/group_vars/neutron_calico_dhcp_agent.yml @@ -27,15 +27,15 @@ # Set to your iBGP ASN bird_bgp_asn: 65000 -bird_bgp_ipv4_peer_ip: "{{ ansible_default_ipv4['gateway'] }}" +bird_bgp_ipv4_peer_ip: "{{ ansible_facts['default_ipv4']['gateway'] }}" #calculate the first address in the subnet since the IPv6 "gateway" may be a #link local address that we cannot peer to. bird_bgp_ipv6_peer_ip: >- - {% if ansible_default_ipv6['address'] is defined - and ansible_default_ipv6['prefix'] is defined %} + {% if ansible_facts['default_ipv6']['address'] is defined + and ansible_facts['default_ipv6']['prefix'] is defined %} {{ - ((ansible_default_ipv6['address'] ~ '/' ~ ansible_default_ipv6['prefix']) | - ipaddr('network') ~ '/' ~ ansible_default_ipv6['prefix'] + ((ansible_facts['default_ipv6']['address'] ~ '/' ~ ansible_facts['default_ipv6']['prefix']) | + ipaddr('network') ~ '/' ~ ansible_facts['default_ipv6']['prefix'] ) | ipaddr('net') | ipaddr(1) | ipaddr('address') }} {% endif %} diff --git a/inventory/group_vars/nova_all.yml b/inventory/group_vars/nova_all.yml index 2843212e66..82a6a9e95d 100644 --- a/inventory/group_vars/nova_all.yml +++ b/inventory/group_vars/nova_all.yml @@ -15,7 +15,7 @@ nova_console_type: novnc -nova_console_agent_enabled: "{{ ansible_architecture != 'aarch64' }}" +nova_console_agent_enabled: "{{ ansible_facts['architecture'] != 'aarch64' }}" nova_novncproxy_port: 6080 nova_spice_html5proxy_base_port: 6082 nova_serialconsoleproxy_port: 6083 diff --git a/inventory/group_vars/utility_all.yml b/inventory/group_vars/utility_all.yml index ad886125c7..67cd205a67 100644 --- a/inventory/group_vars/utility_all.yml +++ b/inventory/group_vars/utility_all.yml @@ -42,7 +42,7 @@ _utility_devel_distro_packages_redhat: - libselinux-python3 - python36-devel -utility_devel_distro_packages: "{{ (ansible_os_family == 'RedHat') | ternary(_utility_devel_distro_packages_redhat, _utility_devel_distro_packages_debian) }}" +utility_devel_distro_packages: "{{ (ansible_facts['os_family'] == 'RedHat') | ternary(_utility_devel_distro_packages_redhat, _utility_devel_distro_packages_debian) }}" # Client packages required for distro installs utility_distro_openstack_clients_packages: @@ -90,7 +90,7 @@ tempest_main_group: utility_all # This sets up a list of tests to execute based on what's deployed in the environment. # The list gets added to the whitelist which tempest executes. tempest_test_whitelist: - - "{{ (ansible_pkg_mgr == 'apt' and tempest_install_method == 'distro') | + - "{{ (ansible_facts['pkg_mgr'] == 'apt' and tempest_install_method == 'distro') | ternary('(?!.*\\.test_list_all_implied_roles)', '') ~ 'tempest.api.identity.admin.v3' }}" - "tempest.api.identity.v3" - "{{ (tempest_service_available_ceilometer | bool) | ternary('tempest.api.telemetry', '') }}"