Use ansible_facts[] instead of fact variables

See https://github.com/ansible/ansible/issues/73654

Change-Id: Ia8eca0c54079f96f1160ac88670392794e7f747a
This commit is contained in:
Jonathan Rosser 2021-02-25 18:58:37 +00:00
parent 6f7483b33c
commit 9c8062fb51
10 changed files with 22 additions and 22 deletions

View File

@ -20,7 +20,7 @@ debug: False
# for the service setup. The host must already have # for the service setup. The host must already have
# clouds.yaml properly configured. # clouds.yaml properly configured.
horizon_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}" horizon_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}"
horizon_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((horizon_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" horizon_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((horizon_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_facts['python']['executable'])) }}"
# Set the package install state for distribution packages # Set the package install state for distribution packages
# Options are 'present' and 'latest' # Options are 'present' and 'latest'
@ -145,7 +145,7 @@ horizon_lib_wsgi_file: "{{ horizon_lib_dir }}/openstack_dashboard/wsgi.py"
horizon_endpoint_type: internalURL horizon_endpoint_type: internalURL
horizon_server_name: "{{ ansible_fqdn | default('horizon') }}" horizon_server_name: "{{ ansible_facts['fqdn'] | default('horizon') }}"
horizon_apache_servertokens: "Prod" horizon_apache_servertokens: "Prod"
horizon_apache_serversignature: "Off" horizon_apache_serversignature: "Off"
horizon_log_level: info horizon_log_level: info
@ -201,7 +201,7 @@ horizon_disallow_iframe_embed: True
## Cap the maximun number of threads / workers when a user value is unspecified. ## Cap the maximun number of threads / workers when a user value is unspecified.
horizon_wsgi_threads_max: 16 horizon_wsgi_threads_max: 16
horizon_wsgi_threads: "{{ [[ansible_processor_vcpus|default(2) // 2, 1] | max, horizon_wsgi_threads_max] | min }}" horizon_wsgi_threads: "{{ [[ansible_facts['processor_vcpus']|default(2) // 2, 1] | max, horizon_wsgi_threads_max] | min }}"
## Horizon SSL ## Horizon SSL
horizon_ssl_cert: /etc/ssl/certs/horizon.pem horizon_ssl_cert: /etc/ssl/certs/horizon.pem

View File

@ -27,6 +27,6 @@
name: "{{ horizon_system_service_name }}" name: "{{ horizon_system_service_name }}"
enabled: yes enabled: yes
state: "restarted" state: "restarted"
daemon_reload: "{{ (ansible_service_mgr == 'systemd') | ternary('yes', omit) }}" daemon_reload: "{{ (ansible_facts['service_mgr'] == 'systemd') | ternary('yes', omit) }}"
listen: listen:
- "venv changed" - "venv changed"

View File

@ -42,4 +42,4 @@ galaxy_info:
dependencies: dependencies:
- role: apt_package_pinning - role: apt_package_pinning
when: when:
- ansible_pkg_mgr == 'apt' - ansible_facts['pkg_mgr'] == 'apt'

View File

@ -23,7 +23,7 @@
with_items: with_items:
- "{{ horizon_apache_modules }}" - "{{ horizon_apache_modules }}"
when: when:
- ansible_pkg_mgr in ['apt', 'zypper'] - ansible_facts['pkg_mgr'] in ['apt', 'zypper']
notify: Restart apache2 notify: Restart apache2
- name: Drop apache2 configs - name: Drop apache2 configs
@ -71,7 +71,7 @@
content: "" content: ""
notify: Restart apache2 notify: Restart apache2
when: ansible_pkg_mgr == 'zypper' when: ansible_facts['pkg_mgr'] == 'zypper'
- name: Enable Horizon Site - name: Enable Horizon Site
file: file:
@ -108,7 +108,7 @@
- name: Remove Listen from Apache config - name: Remove Listen from Apache config
lineinfile: lineinfile:
dest: "{{ horizon_apache_security_conf }}" dest: "{{ horizon_apache_security_conf }}"
regexp: "{{ (ansible_pkg_mgr == 'zypper') | ternary('^(Include.*listen\\.conf)', '^(Listen.*)') }}" regexp: "{{ (ansible_facts['pkg_mgr'] == 'zypper') | ternary('^(Include.*listen\\.conf)', '^(Listen.*)') }}"
backrefs: yes backrefs: yes
line: '#\1' line: '#\1'
notify: Restart apache2 notify: Restart apache2

View File

@ -29,8 +29,8 @@
package: package:
name: "{{ horizon_package_list }}" name: "{{ horizon_package_list }}"
state: "{{ horizon_package_state }}" state: "{{ horizon_package_state }}"
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}" update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}" cache_valid_time: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages register: install_packages
until: install_packages is success until: install_packages is success
retries: 5 retries: 5

View File

@ -23,7 +23,7 @@
with_items: with_items:
- { path: "/etc/pki/tls/certs", owner: "root", group: "root" } - { path: "/etc/pki/tls/certs", owner: "root", group: "root" }
- { path: "/etc/pki/tls/private", owner: "root", group: "root" } - { path: "/etc/pki/tls/private", owner: "root", group: "root" }
when: ansible_pkg_mgr in ['yum', 'dnf'] when: ansible_facts['pkg_mgr'] in ['yum', 'dnf']
- name: Create system links - name: Create system links
file: file:
@ -33,7 +33,7 @@
with_items: with_items:
- { src: "/etc/pki/tls/certs", dest: "/etc/ssl/certs" } - { src: "/etc/pki/tls/certs", dest: "/etc/ssl/certs" }
- { src: "/etc/pki/tls/private", dest: "/etc/ssl/private" } - { src: "/etc/pki/tls/private", dest: "/etc/ssl/private" }
when: ansible_pkg_mgr in ['yum', 'dnf'] when: ansible_facts['pkg_mgr'] in ['yum', 'dnf']
# NOTE(jrosser) # NOTE(jrosser)
# horizon appears in u-c as is it used as a library for the horizon plugins # horizon appears in u-c as is it used as a library for the horizon plugins
@ -179,6 +179,6 @@
- name: Register wsgi module - name: Register wsgi module
shell: "{{ horizon_bin }}/mod_wsgi-express install-module > /etc/httpd/conf.modules.d/02-wsgi.conf" shell: "{{ horizon_bin }}/mod_wsgi-express install-module > /etc/httpd/conf.modules.d/02-wsgi.conf"
when: ansible_os_family | lower == 'redhat' and ansible_distribution_major_version is version('7', '=') when: ansible_facts['os_family'] | lower == 'redhat' and ansible_facts['distribution_major_version'] is version('7', '=')
notify: notify:
- Restart apache2 - Restart apache2

View File

@ -23,7 +23,7 @@
recurse: yes recurse: yes
with_items: with_items:
- { path: "{{ horizon_lib_dir }}", fixup: True } - { path: "{{ horizon_lib_dir }}", fixup: True }
- { path: "/etc/openstack-dashboard", fixup: "{{ (ansible_os_family | lower) == 'redhat' }}" } - { path: "/etc/openstack-dashboard", fixup: "{{ (ansible_facts['os_family'] | lower) == 'redhat' }}" }
when: item.fixup when: item.fixup
# TODO(hwoarang): See if we can use local_settings.py from the distribution packages # TODO(hwoarang): See if we can use local_settings.py from the distribution packages

View File

@ -16,11 +16,11 @@
- name: Gather variables for each operating system - name: Gather variables for each operating system
include_vars: "{{ item }}" include_vars: "{{ item }}"
with_first_found: with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml" - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml" - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml" - "{{ ansible_facts['distribution'] | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml" - "{{ ansible_facts['os_family'] | lower }}.yml"
tags: tags:
- always - always
@ -71,7 +71,7 @@
when: when:
- horizon_enable_ssl | bool - horizon_enable_ssl | bool
- not (horizon_external_ssl | bool) - not (horizon_external_ssl | bool)
- ansible_pkg_mgr == 'apt' - ansible_facts['pkg_mgr'] == 'apt'
tags: tags:
- horizon-config - horizon-config
- horizon-ssl - horizon-ssl

View File

@ -453,7 +453,7 @@ ENFORCE_PASSWORD_CHECK = {{ horizon_enforce_password_check }}
# target installation. # target installation.
# Path to directory containing policy.json files # Path to directory containing policy.json files
{% if horizon_install_method == 'distro' and (ansible_os_family | lower) == 'redhat' %} {% if horizon_install_method == 'distro' and (ansible_facts['os_family'] | lower) == 'redhat' %}
# CentOS has policy files in /etc/openstack-dashboard # CentOS has policy files in /etc/openstack-dashboard
POLICY_FILES_PATH = '/etc/openstack-dashboard' POLICY_FILES_PATH = '/etc/openstack-dashboard'
{% else %} {% else %}

View File

@ -17,5 +17,5 @@ horizon_package_list: "{{ horizon_distro_packages + horizon_service_distro_packa
_horizon_bin: "/usr/bin" _horizon_bin: "/usr/bin"
horizon_manage: >- horizon_manage: >-
{{ ((ansible_os_family | lower) == 'debian') | ternary('/usr/bin/python3', ansible_python.executable) }} {{ ((ansible_facts['os_family'] | lower) == 'debian') | ternary('/usr/bin/python3', ansible_facts['python']['executable']) }}
{{ horizon_lib_dir }}/manage.py {{ horizon_lib_dir }}/manage.py