From 37efa0a4690ae290cd13e394d5d694fa3b3b6eb0 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Mon, 15 Mar 2021 14:09:49 +0000 Subject: [PATCH] Use ansible_facts[] instead of fact variables See https://github.com/ansible/ansible/issues/73654 Change-Id: I83375d4d96fee13c21dc133dbf5a5b8ed64b826a --- defaults/main.yml | 6 +++--- handlers/main.yml | 4 ++-- meta/main.yml | 2 +- tasks/aodh_install.yml | 8 ++++---- tasks/main.yml | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 2dc1209..06b798e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -20,7 +20,7 @@ debug: False # for the service setup. The host must already have # clouds.yaml properly configured. aodh_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}" -aodh_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((aodh_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +aodh_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((aodh_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' @@ -52,7 +52,7 @@ aodh_system_user_home: "/var/lib/{{ aodh_system_user_name }}" ## Database info aodh_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}" -aodh_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((aodh_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +aodh_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((aodh_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}" aodh_db_address: "{{ galera_address | default('127.0.0.1') }}" aodh_database_name: aodh aodh_database_user: aodh @@ -91,7 +91,7 @@ aodh_oslomsg_amqp1_enabled: "{{ aodh_oslomsg_rpc_transport == 'amqp' }}" ## uWSGI setup aodh_wsgi_threads: 1 aodh_wsgi_processes_max: 16 -aodh_wsgi_processes: "{{ [[(ansible_processor_vcpus//ansible_processor_threads_per_core)|default(1), 1] | max * 2, aodh_wsgi_processes_max] | min }}" +aodh_wsgi_processes: "{{ [[(ansible_facts['processor_vcpus']//ansible_facts['processor_threads_per_core'])|default(1), 1] | max * 2, aodh_wsgi_processes_max] | min }}" #Aodh services info aodh_role_name: admin diff --git a/handlers/main.yml b/handlers/main.yml index 7e19d07..b691e57 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -18,7 +18,7 @@ name: "{{ item.service_name }}" enabled: yes state: "stopped" - daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}" + daemon_reload: yes with_items: "{{ filtered_aodh_services }}" register: _stop until: _stop is success @@ -53,7 +53,7 @@ name: "{{ item.service_name }}" enabled: yes state: "started" - daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}" + daemon_reload: yes with_items: "{{ filtered_aodh_services }}" register: _start until: _start is success diff --git a/meta/main.yml b/meta/main.yml index 2edfe71..7b03040 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -40,4 +40,4 @@ galaxy_info: dependencies: - role: apt_package_pinning when: - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' diff --git a/tasks/aodh_install.yml b/tasks/aodh_install.yml index d216053..7909dad 100644 --- a/tasks/aodh_install.yml +++ b/tasks/aodh_install.yml @@ -29,8 +29,8 @@ package: name: "{{ aodh_package_list }}" state: "{{ aodh_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 @@ -40,8 +40,8 @@ package: name: "{{ aodh_test_distro_packages }}" state: "{{ aodh_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 bd53c69..54cacd8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,11 +24,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