From 845e09aa16e96d26edcc79cec8021884304d2136 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Tue, 16 Mar 2021 08:17:33 +0000 Subject: [PATCH] Use ansible_facts[] instead of fact variables See https://github.com/ansible/ansible/issues/73654 Change-Id: I1b938086c57e599e0d89994e4b33f3619916dafa --- defaults/main.yml | 8 ++++---- handlers/main.yml | 2 +- meta/main.yml | 2 +- tasks/main.yml | 10 +++++----- tasks/senlin_install.yml | 4 ++-- vars/main.yml | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 5b2bbec..20ea737 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,7 +26,7 @@ debug: False # for the service setup. The host must already have # clouds.yaml properly configured. senlin_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}" -senlin_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((senlin_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +senlin_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((senlin_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 @@ senlin_fatal_deprecations: False ## Database info senlin_db_setup_host: "{{ openstack_db_setup_host | default('localhost') }}" -senlin_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((senlin_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" +senlin_db_setup_python_interpreter: "{{ openstack_db_setup_python_interpreter | default((senlin_db_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}" senlin_galera_address: "{{ galera_address | default('127.0.0.1') }}" senlin_galera_user: senlin senlin_galera_database: senlin @@ -164,7 +164,7 @@ senlin_service_down_time: 60 ## Cap the maximum number of threads / workers when a user value is unspecified. senlin_api_threads_max: 16 -senlin_api_threads: "{{ [[(ansible_processor_vcpus//ansible_processor_threads_per_core)|default(1), 1] | max * 2, senlin_api_threads_max] | min }}" +senlin_api_threads: "{{ [[(ansible_facts['processor_vcpus']//ansible_facts['processor_threads_per_core'])|default(1), 1] | max * 2, senlin_api_threads_max] | min }}" senlin_service_in_ldap: "{{ service_ldap_backend_enabled | default(False) }}" @@ -242,7 +242,7 @@ senlin_required_secrets: # uWSGI Settings senlin_api_uwsgi_ini_overrides: {} senlin_wsgi_processes_max: 16 -senlin_wsgi_processes: "{{ [[ansible_processor_vcpus|default(1), 1] | max * 2, senlin_wsgi_processes_max] | min }}" +senlin_wsgi_processes: "{{ [[ansible_facts['processor_vcpus']|default(1), 1] | max * 2, senlin_wsgi_processes_max] | min }}" senlin_wsgi_threads: 1 senlin_api_uwsgi_bind_address: "{{ openstack_service_bind_address | default('0.0.0.0') }}" #senlin_api_cfn_uwsgi_bind_address: "{{ openstack_service_bind_address | default('0.0.0.0') }}" diff --git a/handlers/main.yml b/handlers/main.yml index 459a32f..d17943b 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -18,7 +18,7 @@ name: "{{ item.service_name }}" enabled: yes state: "restarted" - daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}" + daemon_reload: yes with_items: "{{ filtered_senlin_services }}" listen: - "venv changed" diff --git a/meta/main.yml b/meta/main.yml index 6523b72..fde26a3 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/main.yml b/tasks/main.yml index fa5e0c7..ef9792c 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/tasks/senlin_install.yml b/tasks/senlin_install.yml index 722893e..77ed54e 100644 --- a/tasks/senlin_install.yml +++ b/tasks/senlin_install.yml @@ -29,8 +29,8 @@ package: name: "{{ senlin_package_list }}" state: "{{ senlin_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/vars/main.yml b/vars/main.yml index bd3b149..07601ca 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -65,7 +65,7 @@ senlin_uwsgi_services: |- senlin_core_files: - tmp_f: "/tmp/api-paste.ini" - target_f: "{{ (senlin_install_method == 'distro' and ansible_os_family == 'RedHat') | ternary('/usr/share/senlin', '/etc/senlin') }}/api-paste.ini" + target_f: "{{ (senlin_install_method == 'distro' and ansible_facts['os_family'] == 'RedHat') | ternary('/usr/share/senlin', '/etc/senlin') }}/api-paste.ini" config_overrides: "{{ senlin_api_paste_ini_overrides }}" config_type: "ini" - condition: "{{ not ((senlin_install_method == 'distro') and ((ansible_os_family | lower) == 'redhat')) }}" + condition: "{{ not ((senlin_install_method == 'distro') and ((ansible_facts['os_family'] | lower) == 'redhat')) }}"