Use ansible_facts[] instead of fact variables

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

Change-Id: I3cf2a30e0929835a84f0502bc4e87522b688b538
This commit is contained in:
Jonathan Rosser 2021-02-25 14:23:52 +00:00
parent 7dd9f42945
commit b6f03470c4
10 changed files with 45 additions and 45 deletions

View File

@ -86,7 +86,7 @@ nova_management_address: "127.0.0.1"
## Database info
nova_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}"
nova_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((nova_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}"
nova_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((nova_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}"
nova_galera_address: "{{ galera_address | default('127.0.0.1') }}"
nova_galera_user: nova
nova_galera_database: nova
@ -209,7 +209,7 @@ nova_spice_html5proxy_base_proto: "{{ openstack_service_publicuri_proto | defaul
nova_spice_html5proxy_base_port: 6082
nova_spice_html5proxy_base_uri: "{{ nova_spice_html5proxy_base_proto }}://{{ external_lb_vip_address }}:{{ nova_spice_html5proxy_base_port }}"
nova_spice_html5proxy_base_url: "{{ nova_spice_html5proxy_base_uri }}/spice_auto.html"
nova_spice_console_agent_enabled: "{{ ansible_architecture != 'aarch64' }}"
nova_spice_console_agent_enabled: "{{ ansible_facts['architecture'] != 'aarch64' }}"
nova_spicehtml5_git_repo: https://gitlab.freedesktop.org/spice/spice-html5.git
nova_spicehtml5_git_install_branch: master
@ -244,7 +244,7 @@ nova_nested_virt_enabled: False
# Uwsgi settings
nova_wsgi_processes_max: 16
nova_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, nova_wsgi_processes_max] | min }}"
nova_wsgi_processes: "{{ [[ansible_facts['processor_vcpus']|default(1), 1] | max * 2, nova_wsgi_processes_max] | min }}"
nova_wsgi_threads: 1
## Nova libvirt
@ -261,9 +261,9 @@ nova_libvirt_hw_disk_discard: '{{ (nova_libvirt_images_rbd_pool | length > 0) |
nova_libvirt_live_migration_inbound_addr: '{{ (nova_management_address == "localhost") | ternary("127.0.0.1", nova_management_address) }}'
## Nova console
nova_console_agent_enabled: "{{ ansible_architecture != 'aarch64' }}"
nova_console_agent_enabled: "{{ ansible_facts['architecture'] != 'aarch64' }}"
# Set the console type. Presently the only options are ["spice", "novnc", "serialconsole"].
nova_console_type: "{{ (ansible_architecture == 'aarch64') | ternary('serialconsole', 'novnc') }}"
nova_console_type: "{{ (ansible_facts['architecture'] == 'aarch64') | ternary('serialconsole', 'novnc') }}"
# Nova console ssl info, presently only used by novnc console type
nova_console_ssl_dir: "/etc/nova/ssl"
@ -370,7 +370,7 @@ nova_rbd_inuse: "{{ (nova_libvirt_images_rbd_pool | length > 0) or (nova_cinder_
## Cap the maximun number of threads / workers when a user value is unspecified.
nova_api_threads_max: 16
nova_api_threads: "{{ [[(ansible_processor_vcpus//ansible_processor_threads_per_core)|default(1), 1] | max * 2, nova_api_threads_max] | min }}"
nova_api_threads: "{{ [[(ansible_facts['processor_vcpus']//ansible_facts['processor_threads_per_core'])|default(1), 1] | max * 2, nova_api_threads_max] | min }}"
## Policy vars
# Provide a list of access controls to update the default policy.json with. These changes will be merged

View File

@ -68,7 +68,7 @@
- name: Set kernel permissions to enable libguestfs features (Ubuntu)
include_tasks: nova_kernel_permissions.yml
when:
- ansible_distribution == 'Ubuntu'
- ansible_facts['distribution'] == 'Ubuntu'
- nova_libvirt_inject_key | bool or nova_libvirt_inject_password | bool
- name: Set libvirtd config
@ -109,7 +109,7 @@
when:
- (nova_libvirtd_listen_tcp == 1) or (nova_libvirtd_listen_tls == 1)
- libvirtd_version is version('5.7', '<')
- ansible_pkg_mgr == 'apt'
- ansible_facts['pkg_mgr'] == 'apt'
notify: Restart libvirt-bin
tags:
- nova-config
@ -124,7 +124,7 @@
backup: "yes"
when:
- (nova_libvirtd_listen_tcp == 0 and nova_libvirtd_listen_tls == 0) or libvirtd_version is version('5.7', '>=')
- ansible_pkg_mgr == 'apt'
- ansible_facts['pkg_mgr'] == 'apt'
notify: Restart libvirt-bin
tags:
- nova-config
@ -140,7 +140,7 @@
when:
- (nova_libvirtd_listen_tcp == 1) or (nova_libvirtd_listen_tls == 1)
- libvirtd_version is version('5.7', '<')
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
- ansible_facts['pkg_mgr'] in ['yum', 'dnf', 'zypper']
notify: Restart libvirt-bin
tags:
- nova-config
@ -155,7 +155,7 @@
backup: "yes"
when:
- (nova_libvirtd_listen_tcp == 0 and nova_libvirtd_listen_tls == 0) or libvirtd_version is version('5.7', '>=')
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
- ansible_facts['pkg_mgr'] in ['yum', 'dnf', 'zypper']
notify: Restart libvirt-bin
tags:
- nova-config
@ -169,7 +169,7 @@
regexp: "^KSM_ENABLED=*"
backup: yes
when:
- ansible_distribution == 'Ubuntu'
- ansible_facts['distribution'] == 'Ubuntu'
notify: Restart libvirt-bin
tags:
- nova-config
@ -178,7 +178,7 @@
- include_tasks: nova_disable_smt.yml
when:
- ansible_architecture == 'ppc64le'
- ansible_facts['architecture'] == 'ppc64le'
tags:
- nova-config
@ -202,7 +202,7 @@
path: /usr/share/OVMF
state: directory
when:
- ansible_os_family == 'Suse'
- ansible_facts['os_family'] == 'Suse'
tags:
- nova-config
- nova-kvm
@ -210,11 +210,11 @@
- name: Symlink UEFI firmware files
file:
src: "{{ (ansible_os_family == 'RedHat') | ternary('/usr/share/OVMF/OVMF_CODE.secboot.fd', '/usr/share/qemu/ovmf-x86_64-ms-code.bin') }}"
src: "{{ (ansible_facts['os_family'] == 'RedHat') | ternary('/usr/share/OVMF/OVMF_CODE.secboot.fd', '/usr/share/qemu/ovmf-x86_64-ms-code.bin') }}"
dest: /usr/share/OVMF/OVMF_CODE.fd
state: link
when:
- ansible_os_family in ['RedHat', 'Suse']
- ansible_facts['os_family'] in ['RedHat', 'Suse']
tags:
- nova-config
- nova-kvm

View File

@ -11,4 +11,4 @@
enabled: yes
state: started
when:
- ansible_pkg_mgr in ['yum', 'dnf', 'apt']
- ansible_facts['pkg_mgr'] in ['yum', 'dnf', 'apt']

View File

@ -16,12 +16,12 @@
- 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 }}-{{ ansible_distribution_version.split('.')[0] }}.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 }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml"
- "{{ ansible_facts['os_family'] | lower }}.yml"
tags:
- always
@ -255,7 +255,7 @@
- "nova_services['nova-compute']['group'] in group_names"
- "nova_discover_hosts_in_cells_interval | int < 1"
vars:
compute_host_to_wait_for: "{{ ansible_nodename }}"
compute_host_to_wait_for: "{{ ansible_facts['nodename'] }}"
tags:
- nova-config

View File

@ -33,14 +33,14 @@
apt_package_pinning_priority: "1000"
apt_pinned_packages: [{ package: "{{ nova_backports_packages | join(' ') }}", release: 'Debian Backports' }]
when:
- ansible_distribution | lower == 'debian'
- ansible_facts['distribution'] | lower == 'debian'
- name: Install distro packages
package:
name: "{{ nova_package_list }}"
state: "{{ nova_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
@ -83,8 +83,8 @@
when:
- nova_install_method == 'source'
- nova_services['nova-compute']['group'] in group_names
- ansible_os_family | lower == 'redhat'
- ansible_distribution_major_version|int <= 7
- ansible_facts['os_family'] | lower == 'redhat'
- ansible_facts['distribution_major_version']|int <= 7
- include_tasks: "consoles/nova_console_{{ nova_console_type }}_install.yml"
when:
@ -105,7 +105,7 @@
name: "{{ item.service }}"
enabled: no
state: stopped
when: item.service in ansible_facts.services and item.type != nova_console_type
when: item.service in ansible_facts['services'] and item.type != nova_console_type
loop:
- service: "nova-novncproxy.service"
type: "novnc"

View File

@ -138,4 +138,4 @@
- name: Set default nova console for ppc64le
set_fact:
nova_console_type: "novnc"
when: ansible_architecture == 'ppc64le'
when: ansible_facts['architecture'] == 'ppc64le'

View File

@ -32,9 +32,9 @@
or cpuinfo_contents.stdout.find('PowerNV') != -1
or (cpuinfo_contents.stdout.find('pSeries') != -1
and cpuinfo_contents.stdout.find('qemu') != -1
and ansible_architecture == 'ppc64le')
and ansible_facts['architecture'] == 'ppc64le')
or (dev_kvm.stat.ischr is defined and dev_kvm.stat.ischr
and ansible_architecture == 'aarch64')
and ansible_facts['architecture'] == 'aarch64')
- name: Register a fact for the nova qemu virt type
set_fact:

View File

@ -19,7 +19,7 @@ compute_driver = {{ nova_compute_driver }}
instances_path = {{ nova_system_home_folder }}/instances
allow_resize_to_same_host = True
{% if ansible_os_family | lower == 'suse' %}
{% if ansible_facts['os_family'] | lower == 'suse' %}
mkisofs_cmd = /usr/bin/mkisofs
{% endif %}

View File

@ -77,7 +77,7 @@ nova_compute_kvm_distro_packages:
- qemu-user
- qemu-block-extra
- qemu-system
- "{{ (ansible_architecture == 'x86_64') | ternary('qemu-system-x86', 'qemu-system-arm') }}"
- "{{ (ansible_facts['architecture'] == 'x86_64') | ternary('qemu-system-x86', 'qemu-system-arm') }}"
- qemu-system-misc
nova_compute_kvm_packages_to_symlink:

View File

@ -32,9 +32,9 @@ nova_service_distro_packages:
- openstack-nova-api
- openstack-nova-conductor
- openstack-nova-scheduler
- "{{ ansible_distribution_major_version is version('8', '<') | ternary('python-memcached', 'python3-memcached') }}"
- "{{ ansible_distribution_major_version is version('8', '<') | ternary('python2-PyMySQL', 'python3-PyMySQL') }}"
- "{{ ansible_distribution_major_version is version('8', '<') | ternary('systemd-python', 'python3-systemd') }}"
- "{{ ansible_facts['distribution_major_version'] is version('8', '<') | ternary('python-memcached', 'python3-memcached') }}"
- "{{ ansible_facts['distribution_major_version'] is version('8', '<') | ternary('python2-PyMySQL', 'python3-PyMySQL') }}"
- "{{ ansible_facts['distribution_major_version'] is version('8', '<') | ternary('systemd-python', 'python3-systemd') }}"
nova_service_extra_distro_packages:
kvm:
@ -52,7 +52,7 @@ nova_compute_packages:
- genisoimage
- kpartx
- nc
- "{{ ansible_distribution_major_version is version('8', '<') | ternary('python-libguestfs', 'python3-libguestfs') }}"
- "{{ ansible_facts['distribution_major_version'] is version('8', '<') | ternary('python-libguestfs', 'python3-libguestfs') }}"
- sysfsutils
nova_compute_barbican_distro_packages:
@ -60,17 +60,17 @@ nova_compute_barbican_distro_packages:
nova_compute_kvm_distro_packages:
- libvirt-daemon-kvm
- "qemu-kvm{% if ansible_distribution_major_version|int <= 7 %}-ev{% endif %}"
- "qemu-kvm{% if ansible_facts['distribution_major_version']|int <= 7 %}-ev{% endif %}"
- libvirt-client
- "{{ (ansible_distribution_major_version|int <= 7) | ternary('libvirt-devel', 'python3-libvirt') }}"
- "{{ (ansible_facts['distribution_major_version']|int <= 7) | ternary('libvirt-devel', 'python3-libvirt') }}"
- nfs-utils
- "{{ (ansible_distribution_major_version|int <= 7) | ternary('libguestfs-devel', 'python3-libguestfs') }}"
- "qemu-img{% if ansible_distribution_major_version|int <= 7 %}-ev{% endif %}"
- "{{ (ansible_architecture == 'aarch64') | ternary('AAVMF', 'OVMF') }}"
- "{{ (ansible_facts['distribution_major_version']|int <= 7) | ternary('libguestfs-devel', 'python3-libguestfs') }}"
- "qemu-img{% if ansible_facts['distribution_major_version']|int <= 7 %}-ev{% endif %}"
- "{{ (ansible_facts['architecture'] == 'aarch64') | ternary('AAVMF', 'OVMF') }}"
nova_compute_kvm_packages_to_symlink: |-
{% set packages = [] %}
{% if ansible_distribution_major_version|int > 7 %}
{% if ansible_facts['distribution_major_version']|int > 7 %}
{% set _ = packages.extend(['python3-libvirt', 'python3-libguestfs']) %}
{% endif %}
{{ packages }}