From 1b6f3273fbdc028393f466969afa380a34ea9e8c Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 15 Mar 2021 17:58:37 +0000 Subject: [PATCH] Use ansible_facts[] instead of fact variables See https://github.com/ansible/ansible/issues/73654 Change-Id: I40b37608f65ec57b26fb10528da63ad54f9a1496 --- defaults/main.yml | 4 ++-- meta/main.yml | 2 +- tasks/designate_install.yml | 4 ++-- tasks/main.yml | 10 +++++----- tests/test-install-designate.yml | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 4c25460..56138d2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -23,7 +23,7 @@ designate_ceilometer_enabled: "{{ (groups['ceilometer_all'] is defined) and (gro # for the service setup. The host must already have # clouds.yaml properly configured. designate_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}" -designate_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((designate_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +designate_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((designate_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' @@ -61,7 +61,7 @@ designate_system_user_home: "/var/lib/{{ designate_system_user_name }}" ## Database info designate_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}" -designate_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((designate_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +designate_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((designate_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}" designate_galera_address: "{{ galera_address | default('127.0.0.1') }}" designate_galera_user: designate designate_galera_database: designate diff --git a/meta/main.yml b/meta/main.yml index 9bd1b80..af32066 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -39,4 +39,4 @@ galaxy_info: dependencies: - role: apt_package_pinning when: - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' diff --git a/tasks/designate_install.yml b/tasks/designate_install.yml index 7e5e062..7b58619 100644 --- a/tasks/designate_install.yml +++ b/tasks/designate_install.yml @@ -29,8 +29,8 @@ package: name: "{{ designate_package_list }}" state: "{{ designate_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/main.yml b/tasks/main.yml index df22c7b..4161c59 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -26,11 +26,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/tests/test-install-designate.yml b/tests/test-install-designate.yml index 2ed0fc9..90e50db 100644 --- a/tests/test-install-designate.yml +++ b/tests/test-install-designate.yml @@ -18,10 +18,10 @@ remote_user: root gather_facts: true vars: - named_config_file: "{{ (ansible_pkg_mgr == 'apt') | ternary('/etc/bind/named.conf.options','/etc/named.conf') }}" - bind_package_name: "{{ (ansible_pkg_mgr == 'apt') | ternary('bind9','bind') }}" - bind_service_name: "{{ (ansible_pkg_mgr == 'apt') | ternary('bind9','named') }}" - bind_service_state: "{{ (ansible_pkg_mgr == 'apt') | ternary('restarted','started') }}" + named_config_file: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('/etc/bind/named.conf.options','/etc/named.conf') }}" + bind_package_name: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('bind9','bind') }}" + bind_service_name: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('bind9','named') }}" + bind_service_state: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('restarted','started') }}" vars_files: - common/test-vars.yml pre_tasks: @@ -43,7 +43,7 @@ owner: 'root' group: 'named' when: - - ansible_pkg_mgr == 'dnf' + - ansible_facts['pkg_mgr'] == 'dnf' - name: Restart bind9 service: