From 049a1aed1e5e14e39b1645d05e7e642aadbfdf50 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 1 Mar 2021 10:29:14 +0000 Subject: [PATCH] Use ansible_facts[] instead of fact variables See https://github.com/ansible/ansible/issues/73654 Change-Id: Ic75eac3e27fd542370a04f9bd946d907f0756061 --- defaults/main.yml | 6 +++--- tasks/main.yml | 14 +++++++------- tasks/tempest_install.yml | 6 +++--- templates/tempest.conf.j2 | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 88816a0a..45674bf3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -35,7 +35,7 @@ tempest_pip_package_state: "latest" # for the service setup. The host must already have # clouds.yaml properly configured. tempest_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}" -tempest_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((tempest_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +tempest_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((tempest_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}" # Toggle whether tempest actually executes tempest_run: no @@ -85,7 +85,7 @@ tempest_log_dir: "/var/log/tempest" tempest_plugins: "{{ _tempest_plugins.values() | sum(start=[]) | selectattr('install', 'equalto', true) | list }}" # tempest_workspace where tempest can be runned -tempest_workspace: "{{ ansible_env.HOME }}/workspace" +tempest_workspace: "{{ ansible_facts['env']['HOME'] }}/workspace" # The location where the test whitelist/blacklist will be placed tempest_test_whitelist_file_path: "{{ tempest_workspace }}/etc/tempest_whitelist.txt" @@ -262,7 +262,7 @@ tempest_pip_packages: # name: ... name to use when uploading to glance (optional) # properties: a dict of custom properties to attach to the image in glance (optional) # : -tempest_images: "{{ tempest_images_map[ansible_architecture] }}" +tempest_images: "{{ tempest_images_map[ansible_facts['architecture']] }}" # The location where images are downloaded to tempest_image_dir: "{{ lookup('env', 'HOME') }}/tempest-images" diff --git a/tasks/main.yml b/tasks/main.yml index 56e0eb4f..b9c2b656 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 @@ -35,7 +35,7 @@ - name: Gather variables for source installs include_vars: source_install.yml when: - - ((tempest_install_method == 'source') or (tempest_install_method == 'distro' and ansible_distribution == 'Ubuntu')) + - ((tempest_install_method == 'source') or (tempest_install_method == 'distro' and ansible_facts['distribution'] == 'Ubuntu')) tags: - always diff --git a/tasks/tempest_install.yml b/tasks/tempest_install.yml index d3ce7f34..c7fdb526 100644 --- a/tasks/tempest_install.yml +++ b/tasks/tempest_install.yml @@ -18,8 +18,8 @@ package: name: "{{ tempest_package_list }}" state: "{{ tempest_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 @@ -31,7 +31,7 @@ # in defaults as in case of non-integrated tests meta handlers from other roles might fail. - name: Install Tempest packages from PIP import_tasks: tempest_install_source.yml - when: (tempest_install_method | default('source')) == 'source' or (tempest_install_method == 'distro' and ansible_distribution == 'Ubuntu') + when: (tempest_install_method | default('source')) == 'source' or (tempest_install_method == 'distro' and ansible_facts['distribution'] == 'Ubuntu') - name: Install stackviz on venv import_role: diff --git a/templates/tempest.conf.j2 b/templates/tempest.conf.j2 index 573069b7..44508418 100644 --- a/templates/tempest.conf.j2 +++ b/templates/tempest.conf.j2 @@ -42,7 +42,7 @@ live_migration = false block_migration_for_live_migration = false block_migrate_cinder_iscsi = false spice_console = true -config_drive = {{ ansible_architecture != 'aarch64' }} +config_drive = {{ ansible_facts['architecture'] != 'aarch64' }} rescue = false enable_instance_password = {{ tempest_enable_instance_password }} interface_attach = false