Use ansible_facts[] instead of fact variables in playbooks
See https://github.com/ansible/ansible/issues/73654 Change-Id: I2c18758c3cb54b171e7b571c21054a69ad67b2ac
This commit is contained in:
parent
3abb80ec09
commit
f1e56a32fe
@ -37,8 +37,8 @@
|
||||
owner: "root"
|
||||
mode: "0755"
|
||||
when:
|
||||
- ansible_pkg_mgr in ['yum', 'dnf']
|
||||
- ansible_service_mgr == 'systemd'
|
||||
- ansible_facts['pkg_mgr'] in ['yum', 'dnf']
|
||||
- ansible_facts['service_mgr'] == 'systemd'
|
||||
|
||||
- name: Add systemd override for PrivateDevices
|
||||
copy:
|
||||
@ -47,8 +47,8 @@
|
||||
[Service]
|
||||
PrivateDevices=false
|
||||
when:
|
||||
- ansible_pkg_mgr in ['yum', 'dnf']
|
||||
- ansible_service_mgr == 'systemd'
|
||||
- ansible_facts['pkg_mgr'] in ['yum', 'dnf']
|
||||
- ansible_facts['service_mgr'] == 'systemd'
|
||||
|
||||
roles:
|
||||
- role: ceph-defaults
|
||||
|
@ -21,7 +21,7 @@
|
||||
vars:
|
||||
ansible_python_interpreter: >-
|
||||
{{ openstack_service_setup_host_python_interpreter |
|
||||
default((openstack_service_setup_host | default('localhost') == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}
|
||||
default((openstack_service_setup_host | default('localhost') == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}
|
||||
tags:
|
||||
- ceph-rgw
|
||||
- ceph-rgw-setup
|
||||
|
@ -28,7 +28,7 @@
|
||||
name: libselinux-python3
|
||||
state: present
|
||||
when:
|
||||
- ansible_pkg_mgr in ['yum', 'dnf']
|
||||
- ansible_facts['pkg_mgr'] in ['yum', 'dnf']
|
||||
|
||||
# Set the priority of the ceph community apt repo either above or below that of UCA or distro sources
|
||||
- name: Set apt package pins
|
||||
@ -39,9 +39,9 @@
|
||||
apt_package_pinning_priority: "{{ (ceph_repository == 'community') | ternary(1000, 100) }}"
|
||||
apt_pinned_packages: [{ package: '*', release: 'ceph.com' }]
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
- ansible_facts['pkg_mgr'] == 'apt'
|
||||
|
||||
- name: Install python3-yaml
|
||||
package:
|
||||
name: "{{ (ansible_os_family | lower == 'debian') | ternary('python3-yaml', 'python3-pyyaml') }}"
|
||||
name: "{{ (ansible_facts['os_family'] | lower == 'debian') | ternary('python3-yaml', 'python3-pyyaml') }}"
|
||||
state: present
|
||||
|
@ -48,17 +48,8 @@
|
||||
sleep: "{{ lxc_container_wait_params.sleep | default(omit) }}"
|
||||
timeout: "{{ lxc_container_wait_params.timeout | default(omit) }}"
|
||||
|
||||
# When using gather_facts with smart gathering,
|
||||
# the facts aren't fully updated unless they
|
||||
# are old. Using the setup module in a task
|
||||
# does a more thorough collection.
|
||||
# Given we've just created the container, it is
|
||||
# best that we do a full collection of facts -
|
||||
# otherwise we end up with a stale set which
|
||||
# has stuff like the hostname = localhost.
|
||||
- name: Gather facts for new container(s)
|
||||
setup:
|
||||
gather_subset: "network,hardware,virtual"
|
||||
- name: Clear facts for new container(s)
|
||||
meta: clear_facts
|
||||
|
||||
- name: Gather lxc containers facts
|
||||
hosts: all_lxc_containers
|
||||
|
@ -89,7 +89,7 @@
|
||||
retries: 5
|
||||
delay: 15
|
||||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
- ansible_facts['pkg_mgr'] == 'apt'
|
||||
|
||||
- name: Update package cache (zypper)
|
||||
zypper_repository:
|
||||
@ -100,7 +100,7 @@
|
||||
retries: 5
|
||||
delay: 15
|
||||
when:
|
||||
- ansible_pkg_mgr == 'zypper'
|
||||
- ansible_facts['pkg_mgr'] == 'zypper'
|
||||
|
||||
# When using gather_facts with smart gathering,
|
||||
# the facts aren't fully updated unless they
|
||||
|
@ -69,7 +69,7 @@ zun_install_method: distro
|
||||
|
||||
## Delegate all database setup tasks to the utility host, and use the utility venv python interpreter
|
||||
openstack_db_setup_host: "{{ groups['utility_all'][0] }}"
|
||||
openstack_db_setup_python_interpreter: "{{ ansible_python['executable'] }}"
|
||||
openstack_db_setup_python_interpreter: "{{ ansible_facts['python']['executable'] }}"
|
||||
|
||||
openstack_service_setup_host: "{{ groups['utility_all'][0] }}"
|
||||
openstack_service_setup_host_python_interpreter: "/usr/bin/python3"
|
||||
|
@ -46,7 +46,7 @@
|
||||
- name: Ensure the physical host has all the proper interfaces defined
|
||||
assert:
|
||||
that:
|
||||
- item.value.bridge in hostvars[physical_host]['ansible_interfaces']
|
||||
- item.value.bridge in hostvars[physical_host]['ansible_facts']['interfaces']
|
||||
with_dict: "{{ container_networks }}"
|
||||
|
||||
- name: Check if dns resolution and external connectivity is fine
|
||||
@ -73,7 +73,7 @@
|
||||
tasks:
|
||||
- name: Open modules file
|
||||
slurp:
|
||||
src: "{{ (ansible_os_family | lower == 'debian') | ternary('/etc/modules', '/etc/modules-load.d/openstack-ansible.conf') }}"
|
||||
src: "{{ (ansible_facts['os_family'] | lower == 'debian') | ternary('/etc/modules', '/etc/modules-load.d/openstack-ansible.conf') }}"
|
||||
register: modules_file
|
||||
|
||||
- name: Open sysctl file
|
||||
@ -105,12 +105,12 @@
|
||||
|
||||
- name: Check for systat file
|
||||
stat:
|
||||
path: "{{ (ansible_os_family | lower == 'debian') | ternary('/etc/default/sysstat', '/etc/sysconfig/sysstat') }}"
|
||||
path: "{{ (ansible_facts['os_family'] | lower == 'debian') | ternary('/etc/default/sysstat', '/etc/sysconfig/sysstat') }}"
|
||||
register: systat_file
|
||||
|
||||
- name: Check for ssh dir
|
||||
stat:
|
||||
path: "{{ ansible_env.HOME }}/.ssh"
|
||||
path: "{{ ansible_facts['env']['HOME'] }}/.ssh"
|
||||
register: ssh_dir
|
||||
|
||||
- name: Check role functions
|
||||
@ -119,8 +119,8 @@
|
||||
- "'dm_multipath' in modules_content"
|
||||
- "'ebtables' in modules_content"
|
||||
- "'vm.swappiness' in sysctl_content"
|
||||
- "'172.29.236.100 {{ ansible_fqdn }} {{ ansible_hostname }}' in hosts_content"
|
||||
- "'{{ hostvars[groups['galera_all'][0]]['container_address'] }} {{ hostvars[groups['galera_all'][0]]['ansible_hostname'] }}.openstack.local {{ hostvars[groups['galera_all'][0]]['ansible_hostname'] ~ ((hostvars[groups['galera_all'][0]]['ansible_hostname'] != groups['galera_all'][0]) | ternary(' ' ~ groups['galera_all'][0], '')) }}' in hosts_content"
|
||||
- "'172.29.236.100 {{ ansible_facts['fqdn'] }} {{ ansible_facts['hostname'] }}' in hosts_content"
|
||||
- "'{{ hostvars[groups['galera_all'][0]]['container_address'] }} {{ hostvars[groups['galera_all'][0]]['ansible_facts']['hostname'] }}.openstack.local {{ hostvars[groups['galera_all'][0]]['ansible_facts']['hostname'] ~ ((hostvars[groups['galera_all'][0]]['ansible_facts']['hostname'] != groups['galera_all'][0]) | ternary(' ' ~ groups['galera_all'][0], '')) }}' in hosts_content"
|
||||
- "release_file.stat.exists"
|
||||
- "systat_file.stat.exists"
|
||||
- "'PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' in environment_content"
|
||||
|
@ -50,7 +50,7 @@
|
||||
when: groups['haproxy'] | length > 1
|
||||
|
||||
- package:
|
||||
name: "{% if ansible_os_family | lower == 'redhat' %}nmap-ncat{% else %}netcat-openbsd{% endif %}"
|
||||
name: "{% if ansible_facts['os_family'] | lower == 'redhat' %}nmap-ncat{% else %}netcat-openbsd{% endif %}"
|
||||
state: present
|
||||
|
||||
# Fails if HAProxy is not running
|
||||
@ -97,7 +97,7 @@
|
||||
vars_files:
|
||||
- "defaults/{{ install_method }}_install.yml"
|
||||
vars:
|
||||
ansible_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default(ansible_python['executable']) }}"
|
||||
ansible_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default(ansible_facts['python']['executable']) }}"
|
||||
tasks:
|
||||
- name: Get openstack client config
|
||||
openstack.cloud.os_client_config:
|
||||
@ -121,7 +121,7 @@
|
||||
with_items: "{{ groups['memcached'] }}"
|
||||
|
||||
- package:
|
||||
name: "{% if ansible_os_family | lower == 'redhat' %}nmap-ncat{% else %}netcat-openbsd{% endif %}"
|
||||
name: "{% if ansible_facts['os_family'] | lower == 'redhat' %}nmap-ncat{% else %}netcat-openbsd{% endif %}"
|
||||
state: present
|
||||
|
||||
- name: Connect to remote memcache servers (full mesh testing)
|
||||
|
@ -35,7 +35,7 @@
|
||||
- name: Omit suse from this playbook
|
||||
meta: end_play
|
||||
when:
|
||||
- ansible_pkg_mgr == 'zypper'
|
||||
- ansible_facts['pkg_mgr'] == 'zypper'
|
||||
|
||||
- name: Skip playbook if log_hosts group is empty
|
||||
meta: end_play
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
- name: Install systemd-journal-remote
|
||||
package:
|
||||
name: "{{ systemd_journal_remote_distro_package[ansible_pkg_mgr] }}"
|
||||
name: "{{ systemd_journal_remote_distro_package[ansible_facts['pkg_mgr']] }}"
|
||||
state: "{{ package_state }}"
|
||||
|
||||
- name: Ensure systemd-journal-remote socket is enabled on receiving host
|
||||
|
@ -17,7 +17,7 @@
|
||||
# that Ubuntu nodes may not have python by default. Ansible doesn't work very
|
||||
# well if Python isn't installed.
|
||||
#
|
||||
# Also, we can't use a 'when' to check for the ansible_pkg_mgr here because
|
||||
# Also, we can't use a 'when' to check for the ansible_facts['pkg_mgr'] here because
|
||||
# we haven't gathered facts yet.
|
||||
- name: Install Ansible prerequisites
|
||||
hosts: "{{ openstack_host_group|default('hosts') }}"
|
||||
@ -41,7 +41,14 @@
|
||||
|
||||
- name: Gather host facts
|
||||
hosts: "{{ openstack_host_group|default('hosts') }}"
|
||||
gather_facts: "{{ osa_gather_facts | default(True) }}"
|
||||
tasks:
|
||||
- setup:
|
||||
gather_subset:
|
||||
- '!all'
|
||||
- min
|
||||
- virtual
|
||||
when:
|
||||
- osa_gather_facts | default(True)
|
||||
tags:
|
||||
- always
|
||||
|
||||
@ -53,17 +60,17 @@
|
||||
- name: Check for a supported Operating System
|
||||
assert:
|
||||
that:
|
||||
- (ansible_distribution == 'Debian' and ansible_distribution_release == 'buster') or
|
||||
(ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'bionic') or
|
||||
(ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'focal') or
|
||||
(ansible_os_family == 'RedHat' and ansible_distribution_major_version == '8')
|
||||
- (ansible_facts['distribution'] == 'Debian' and ansible_facts['distribution_release'] == 'buster') or
|
||||
(ansible_facts['distribution'] == 'Ubuntu' and ansible_facts['distribution_release'] == 'bionic') or
|
||||
(ansible_facts['distribution'] == 'Ubuntu' and ansible_facts['distribution_release'] == 'focal') or
|
||||
(ansible_facts['os_family'] == 'RedHat' and ansible_facts['distribution_major_version'] == '8')
|
||||
msg: >
|
||||
The only supported platforms for this release are Debian 10 (Buster),
|
||||
Ubuntu 18.04 LTS (Bionic), Ubuntu 20.04 LTS (Focal) and CentOS 8
|
||||
- name: Check for a supported path
|
||||
assert:
|
||||
that:
|
||||
- not (ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'bionic' and install_method == 'distro')
|
||||
- not (ansible_facts['distribution'] == 'Ubuntu' and ansible_facts['distribution_release'] == 'bionic' and install_method == 'distro')
|
||||
msg: Distro installation path is not supported for this release for Ubuntu 18.04 (bionic)
|
||||
roles:
|
||||
- role: "openstack_hosts"
|
||||
|
@ -21,4 +21,4 @@
|
||||
group: "root"
|
||||
mode: "0644"
|
||||
when:
|
||||
- ansible_os_family == 'Debian'
|
||||
- ansible_facts['os_family'] == 'Debian'
|
||||
|
@ -80,7 +80,7 @@
|
||||
block:
|
||||
- name: Download EPEL gpg keys
|
||||
get_url:
|
||||
url: "{{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_distribution_major_version) }}"
|
||||
url: "{{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_facts['distribution_major_version']) }}"
|
||||
dest: /etc/pki/rpm-gpg
|
||||
register: _get_yum_keys
|
||||
until: _get_yum_keys is success
|
||||
@ -89,15 +89,15 @@
|
||||
|
||||
- name: Install EPEL gpg keys
|
||||
rpm_key:
|
||||
key: "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}"
|
||||
key: "/etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-{{ ansible_facts['ansible_distribution_major_version'] }}"
|
||||
state: present
|
||||
|
||||
- name: Install the EPEL repository
|
||||
yum_repository:
|
||||
name: epel-utility
|
||||
baseurl: "{{ centos_epel_mirror | default('http://download.fedoraproject.org/pub/epel') ~ '/'
|
||||
~ ansible_distribution_major_version ~ '/'
|
||||
~ ansible_architecture }}"
|
||||
~ ansible_facts['distribution_major_version'] ~ '/'
|
||||
~ ansible_facts['architecture'] }}"
|
||||
description: 'Extra Packages for Enterprise Linux 7 - $basearch'
|
||||
gpgcheck: yes
|
||||
enabled: yes
|
||||
@ -109,15 +109,15 @@
|
||||
delay: 2
|
||||
when:
|
||||
- install_method == "distro"
|
||||
- ansible_os_family | lower == 'redhat'
|
||||
- ansible_facts['os_family'] | lower == 'redhat'
|
||||
- ansible_distribution_major_version is version('8', '<')
|
||||
|
||||
- name: Install distro packages
|
||||
package:
|
||||
name: "{{ utility_distro_packages | default([]) }}"
|
||||
state: "{{ utility_package_state }}"
|
||||
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
|
||||
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
|
||||
update_cache: "{{ (ansible_facts['pkg_mgr'] in ['apt', 'zypper']) | ternary('yes', omit) }}"
|
||||
cache_valid_time: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary(cache_timeout, omit) }}"
|
||||
register: install_packages
|
||||
until: install_packages is success
|
||||
retries: 5
|
||||
|
Loading…
Reference in New Issue
Block a user