Use ansible_facts[] instead of fact variables

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

Change-Id: Ie427a6343fd888c9a1dd5c37a6285d33cd008b3e
This commit is contained in:
Jonathan Rosser 2021-03-16 08:25:35 +00:00 committed by Andrew Bonney
parent f1c847b1df
commit 599e30daaa
5 changed files with 31 additions and 31 deletions

View File

@ -33,7 +33,7 @@ zun_venv_python_executable: "{{ openstack_venv_python_executable | default('pyth
# for the service setup. The host must already have
# clouds.yaml properly configured.
zun_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}"
zun_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((zun_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}"
zun_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((zun_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}"
# Set the package install state for distribution packages
# Options are 'present' and 'latest'
@ -122,7 +122,7 @@ zun_docker_prune_frequency: hour
## Database info
zun_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}"
zun_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((zun_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}"
zun_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((zun_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}"
zun_galera_address: "{{ galera_address | default('127.0.0.1') }}"
zun_galera_user: zun
zun_galera_database: zun
@ -230,7 +230,7 @@ zun_container_runtime: runc
## Cap the maximun number of threads / workers when a user value is unspecified.
zun_api_threads_max: 16
zun_api_threads: "{{ [[(ansible_processor_vcpus//ansible_processor_threads_per_core)|default(1), 1] | max * 2, zun_api_threads_max] | min }}"
zun_api_threads: "{{ [[(ansible_facts['processor_vcpus']//ansible_facts['processor_threads_per_core'])|default(1), 1] | max * 2, zun_api_threads_max] | min }}"
zun_service_in_ldap: "{{ service_ldap_backend_enabled | default(False) }}"
@ -244,7 +244,7 @@ zun_scheduler_driver: filter_scheduler
## uWSGI setup
zun_wsgi_threads: 1
zun_wsgi_processes_max: 16
zun_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, zun_wsgi_processes_max] | min }}"
zun_wsgi_processes: "{{ [[ansible_facts['processor_vcpus']|default(1), 1] | max * 2, zun_wsgi_processes_max] | min }}"
## Service Name-Group Mapping
zun_services:

View File

@ -16,11 +16,11 @@
- name: Gather variables for each operating system
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml"
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml"
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_facts['distribution'] | lower }}.yml"
- "{{ ansible_facts['os_family'] | lower }}.yml"
tags:
- always

View File

@ -73,7 +73,7 @@
delay: 2
when:
- "ansible_pkg_mgr == 'apt'"
- "ansible_facts['pkg_mgr'] == 'apt'"
- name: Add docker repo
yum_repository:
@ -90,7 +90,7 @@
delay: 2
with_items: "{{ zun_docker_repo }}"
when:
- ansible_pkg_mgr == 'dnf'
- ansible_facts['pkg_mgr'] == 'dnf'
- name: Enable module_hotfixes
lineinfile:
@ -100,15 +100,15 @@
insertafter: "^enabled"
with_items: "{{ zun_docker_repo }}"
when:
- ansible_os_family | lower == 'redhat'
- ansible_facts['os_family'] | lower == 'redhat'
- name: Install compute distro packages
package:
name: "{{ zun_distro_compute_packages }}"
state: "{{ zun_package_state }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
enablerepo: "{{ (ansible_pkg_mgr == 'dnf') | ternary('extras', omit) }}"
update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary(cache_timeout, omit) }}"
enablerepo: "{{ (ansible_facts['pkg_mgr'] == 'dnf') | ternary('extras', omit) }}"
- name: Ensure the containerd config directory exists
file:
@ -267,7 +267,7 @@
command:
cmd: "/sbin/mpathconf --enable"
creates: "/etc/multipath.conf"
when: ansible_os_family == "RedHat"
when: ansible_facts['os_family'] == "RedHat"
- name: Enable multipathd service
systemd:

View File

@ -15,18 +15,18 @@
_zun_docker_package_version: "5:19.03.14~*"
_zun_containerd_package_version: "1.4.3-1"
_zun_kata_package_version: "{{ (ansible_distribution_release | lower == 'focal') | ternary('1.12.0-2', '1.11.5-9') }}"
_zun_kata_package_version: "{{ (ansible_facts['distribution_release'] | lower == 'focal') | ternary('1.12.0-2', '1.11.5-9') }}"
zun_kata_repo_version: "{{ (ansible_distribution_release | lower == 'focal') | ternary('stable-1.12', 'stable-1.11') }}"
zun_kata_repo_distro: "{{ (ansible_distribution | lower == 'ubuntu') | ternary('x', '') }}{{ ansible_distribution | capitalize }}"
zun_kata_repo_version: "{{ (ansible_facts['distribution_release'] | lower == 'focal') | ternary('stable-1.12', 'stable-1.11') }}"
zun_kata_repo_distro: "{{ (ansible_facts['distribution'] | lower == 'ubuntu') | ternary('x', '') }}{{ ansible_facts['distribution'] | capitalize }}"
zun_docker_repo:
- name: "docker-ce"
repo: "deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release | lower }} stable"
gpg_uri: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
repo: "deb [arch=amd64] https://download.docker.com/linux/{{ ansible_facts['distribution'] | lower }} {{ ansible_facts['distribution_release'] | lower }} stable"
gpg_uri: "https://download.docker.com/linux/{{ ansible_facts['distribution'] | lower }}/gpg"
- name: "kata"
repo: "deb https://download.opensuse.org/repositories/home:/katacontainers:/releases:/{{ ansible_architecture }}:/{{ zun_kata_repo_version }}/{{ zun_kata_repo_distro }}_{{ ansible_distribution_version }}/ /"
gpg_uri: "https://download.opensuse.org/repositories/home:/katacontainers:/releases:/{{ ansible_architecture }}:/{{ zun_kata_repo_version }}/{{ zun_kata_repo_distro }}_{{ ansible_distribution_version }}/Release.key"
repo: "deb https://download.opensuse.org/repositories/home:/katacontainers:/releases:/{{ ansible_facts['architecture'] }}:/{{ zun_kata_repo_version }}/{{ zun_kata_repo_distro }}_{{ ansible_facts['distribution_version'] }}/ /"
gpg_uri: "https://download.opensuse.org/repositories/home:/katacontainers:/releases:/{{ ansible_facts['architecture'] }}:/{{ zun_kata_repo_version }}/{{ zun_kata_repo_distro }}_{{ ansible_facts['distribution_version'] }}/Release.key"
# Common apt packages
zun_distro_packages:

View File

@ -20,11 +20,11 @@ _zun_kata_package_version: "1.11.3-1"
zun_docker_repo:
- name: "docker-ce"
description: Docker CE Stable
repo: "https://download.docker.com/linux/centos/{{ ansible_distribution_major_version }}/$basearch/stable"
repo: "https://download.docker.com/linux/centos/{{ ansible_facts['distribution_major_version'] }}/$basearch/stable"
gpgkey: "https://download.docker.com/linux/centos/gpg"
- name: "kata"
description: Kata runtime
repo: "http://mirror.centos.org/centos/{{ ansible_distribution_major_version }}/virt/$basearch/kata-containers"
repo: "http://mirror.centos.org/centos/{{ ansible_facts['distribution_major_version'] }}/virt/$basearch/kata-containers"
gpgkey: "http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-Official"
# Common yum packages
@ -33,15 +33,15 @@ zun_distro_packages:
- systemd-devel
zun_distro_compute_packages:
- "containerd.io-{{ zun_containerd_package_version }}.el{{ ansible_distribution_major_version }}.x86_64"
- "docker-ce-cli-{{ zun_docker_package_version }}.el{{ ansible_distribution_major_version }}.x86_64"
- "docker-ce-{{ zun_docker_package_version }}.el{{ ansible_distribution_major_version }}.x86_64"
- "containerd.io-{{ zun_containerd_package_version }}.el{{ ansible_facts['distribution_major_version'] }}.x86_64"
- "docker-ce-cli-{{ zun_docker_package_version }}.el{{ ansible_facts['distribution_major_version'] }}.x86_64"
- "docker-ce-{{ zun_docker_package_version }}.el{{ ansible_facts['distribution_major_version'] }}.x86_64"
- pciutils
- numactl
- device-mapper-multipath
- "kata-runtime-{{ zun_kata_package_version }}.el{{ ansible_distribution_major_version }}.x86_64"
- "kata-shim-{{ zun_kata_package_version }}.el{{ ansible_distribution_major_version }}.x86_64"
- "kata-runtime-{{ zun_kata_package_version }}.el{{ ansible_facts['distribution_major_version'] }}.x86_64"
- "kata-shim-{{ zun_kata_package_version }}.el{{ ansible_facts['distribution_major_version'] }}.x86_64"
# NOTE: This package is unavailable from the centos mirrors
# - "kata-proxy-{{ zun_kata_package_version }}.el{{ ansible_distribution_major_version }}.x86_64"
# - "kata-proxy-{{ zun_kata_package_version }}.el{{ ansible_facts['distribution_major_version'] }}.x86_64"
zun_docker_groupname: docker