From 0495f54875eccf95078c7944dd8da0338a30ee7f Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Thu, 25 Feb 2021 18:41:28 +0000 Subject: [PATCH] Use ansible_facts[] instead of fact variables See https://github.com/ansible/ansible/issues/73654 Change-Id: I9aaeee50a4d07159a7a8a886c27eceee04c162b9 --- defaults/main.yml | 8 ++++---- doc/source/app-opendaylight.rst | 2 +- tasks/main.yml | 10 +++++----- tasks/neutron_install.yml | 6 +++--- tasks/neutron_post_install.yml | 8 ++++---- tasks/neutron_pre_install.yml | 2 +- tasks/providers/ovn_config.yml | 8 ++++---- tasks/providers/setup_ovs_dpdk.yml | 2 +- tasks/providers/setup_ovs_ovn.yml | 2 +- vars/main.yml | 2 +- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 1d895365..a9f8050d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -28,7 +28,7 @@ debug: False # for the service setup. The host must already have # clouds.yaml properly configured. neutron_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}" -neutron_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((neutron_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +neutron_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((neutron_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}" ### ### Packages Options @@ -96,7 +96,7 @@ neutron_fatal_deprecations: False ## Cap the maximun number of threads / workers when a user value is unspecified. neutron_api_threads_max: 16 -neutron_api_threads: "{{ [[ansible_processor_vcpus|default(2) // 2, 1] | max, neutron_api_threads_max] | min }}" +neutron_api_threads: "{{ [[ansible_facts['processor_vcpus']|default(2) // 2, 1] | max, neutron_api_threads_max] | min }}" neutron_agent_down_time: 120 neutron_agent_polling_interval: 5 @@ -209,7 +209,7 @@ neutron_quota_firewall_rule: 100 ### neutron_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}" -neutron_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((neutron_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +neutron_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((neutron_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}" neutron_galera_address: "{{ galera_address | default('127.0.0.1') }}" neutron_galera_user: neutron neutron_galera_database: neutron @@ -261,7 +261,7 @@ neutron_rpc_thread_pool_size: 64 neutron_rpc_conn_pool_size: 30 neutron_rpc_response_timeout: 60 neutron_rpc_workers_max: 16 -neutron_rpc_workers: "{{ [[(ansible_processor_vcpus//ansible_processor_threads_per_core)|default(1), 1] | max * 2, neutron_rpc_workers_max] | min }}" +neutron_rpc_workers: "{{ [[(ansible_facts['processor_vcpus']//ansible_facts['processor_threads_per_core'])|default(1), 1] | max * 2, neutron_rpc_workers_max] | min }}" ### ### Identity (Keystone) integration diff --git a/doc/source/app-opendaylight.rst b/doc/source/app-opendaylight.rst index 36fed877..c7c9a84a 100644 --- a/doc/source/app-opendaylight.rst +++ b/doc/source/app-opendaylight.rst @@ -43,7 +43,7 @@ Set the following user variables in your ### Use OpenDaylight SDN Controller neutron_plugin_type: "ml2.opendaylight" - odl_ip: "{{ hostvars[groups['opendaylight'][0]]['ansible_default_ipv4']['address'] }}" + odl_ip: "{{ hostvars[groups['opendaylight'][0]]['ansible_facts']['default_ipv4']['address'] }}" neutron_opendaylight_conf_ini_overrides: ml2_odl: url: "http://{{ odl_ip }}:8180/controller/nb/v2/neutron" diff --git a/tasks/main.yml b/tasks/main.yml index 9f3e792b..8cb7c729 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -19,11 +19,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 diff --git a/tasks/neutron_install.yml b/tasks/neutron_install.yml index 89621fdb..466bd1b4 100644 --- a/tasks/neutron_install.yml +++ b/tasks/neutron_install.yml @@ -29,8 +29,8 @@ package: name: "{{ neutron_package_list }}" state: "{{ neutron_package_state }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" - cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | 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 @@ -130,5 +130,5 @@ - import_tasks: neutron_apparmor.yml when: - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' - inventory_hostname in neutron_apparmor_hosts diff --git a/tasks/neutron_post_install.yml b/tasks/neutron_post_install.yml index ac7976d7..a5c71943 100644 --- a/tasks/neutron_post_install.yml +++ b/tasks/neutron_post_install.yml @@ -93,7 +93,7 @@ group: "{{ neutron_system_group_name }}" mode: "0640" state: link - when: neutron_install_method == 'distro' and ansible_os_family == 'RedHat' + when: neutron_install_method == 'distro' and ansible_facts['os_family'] == 'RedHat' - name: Create symlink to neutron-keepalived-state-change file: @@ -204,7 +204,7 @@ state: stopped enabled: false when: - - ansible_pkg_mgr == 'apt' - - ansible_hostname in groups['neutron_metadata_agent'] + - ansible_facts['pkg_mgr'] == 'apt' + - ansible_facts['hostname'] in groups['neutron_metadata_agent'] - groups['haproxy_all'] is defined - - ansible_hostname not in groups['haproxy_all'] + - ansible_facts['hostname'] not in groups['haproxy_all'] diff --git a/tasks/neutron_pre_install.yml b/tasks/neutron_pre_install.yml index a15d71a8..39e0f98b 100644 --- a/tasks/neutron_pre_install.yml +++ b/tasks/neutron_pre_install.yml @@ -102,7 +102,7 @@ retries: 5 delay: 2 when: - - ansible_pkg_mgr == 'dnf' + - ansible_facts['pkg_mgr'] == 'dnf' - neutron_needs_openvswitch | bool - name: Create ovs tempfiles directory diff --git a/tasks/providers/ovn_config.yml b/tasks/providers/ovn_config.yml index b2053ebe..1b8ab07a 100644 --- a/tasks/providers/ovn_config.yml +++ b/tasks/providers/ovn_config.yml @@ -18,8 +18,8 @@ package: name: "{{ neutron_ovn_northd_distro_packages }}" state: "{{ neutron_package_state }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" - cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | 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 @@ -31,8 +31,8 @@ package: name: "{{ neutron_ovn_controller_distro_packages }}" state: "{{ neutron_package_state }}" - update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" - cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}" + update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | 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 diff --git a/tasks/providers/setup_ovs_dpdk.yml b/tasks/providers/setup_ovs_dpdk.yml index f99a10d6..7a23ac47 100644 --- a/tasks/providers/setup_ovs_dpdk.yml +++ b/tasks/providers/setup_ovs_dpdk.yml @@ -18,7 +18,7 @@ name: ovs-vswitchd path: /usr/lib/openvswitch-switch-dpdk/ovs-vswitchd-dpdk when: - - ansible_pkg_mgr in ['apt'] + - ansible_facts['pkg_mgr'] in ['apt'] - neutron_services['neutron-openvswitch-agent']['group'] in group_names - '"nova_compute" in group_names' diff --git a/tasks/providers/setup_ovs_ovn.yml b/tasks/providers/setup_ovs_ovn.yml index 6d0de82b..9ad89e0a 100644 --- a/tasks/providers/setup_ovs_ovn.yml +++ b/tasks/providers/setup_ovs_ovn.yml @@ -15,7 +15,7 @@ # limitations under the License. - name: Set openvswitch hostname - command: "ovs-vsctl set open_vswitch . external-ids:hostname='{{ ansible_hostname }}'" + command: "ovs-vsctl set open_vswitch . external-ids:hostname='{{ ansible_facts['hostname'] }}'" when: - (neutron_services['neutron-ovn-northd']['group'] in group_names) or (neutron_services['neutron-ovn-controller']['group'] in group_names) diff --git a/vars/main.yml b/vars/main.yml index a94de306..8c2c50df 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -253,7 +253,7 @@ opendaylight_extra_features: |- {%- endif -%} {{ features }} -opendaylight_install_method: "{{ (ansible_os_family=='Debian') | ternary('deb_repo', 'rpm_repo') }}" +opendaylight_install_method: "{{ (ansible_facts['os_family']=='Debian') | ternary('deb_repo', 'rpm_repo') }}" ovs_manager_list: |- {% set ovs_managers_odls = [] %}