Use ansible_facts[] instead of fact variables

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

Change-Id: Ia6dac13c7e2206f4a86ef8e21c5b1cd80eb16e0e
This commit is contained in:
Jonathan Rosser 2021-02-23 09:23:06 +00:00
parent 5d0ae7e145
commit b8fc872113
12 changed files with 34 additions and 34 deletions

View File

@ -34,11 +34,11 @@ rabbit_system_group_name: rabbitmq
rabbitmq_hosts_entries: >- rabbitmq_hosts_entries: >-
{{ groups[rabbitmq_host_group] | map('extract', hostvars) | list | {{ groups[rabbitmq_host_group] | map('extract', hostvars) | list |
json_query( json_query(
"[].{address: rabbitmq_node_address || ansible_host , hostnames: [ansible_hostname, ansible_fqdn] }" "[].{address: rabbitmq_node_address || ansible_host , hostnames: [ansible_facts.hostname, ansible_facts.fqdn] }"
) )
}} }}
rabbitmq_primary_cluster_node: "{{ hostvars[groups[rabbitmq_host_group][0]]['ansible_hostname'] }}" rabbitmq_primary_cluster_node: "{{ hostvars[groups[rabbitmq_host_group][0]]['ansible_facts']['hostname'] }}"
# Upgrading the RabbitMQ package requires shutting down the cluster. This variable makes upgrading # Upgrading the RabbitMQ package requires shutting down the cluster. This variable makes upgrading
# the version an explicit action. # the version an explicit action.
@ -110,7 +110,7 @@ rabbitmq_ssl_ca_cert: /etc/rabbitmq/rabbitmq-ca.pem
# SSL certificate for RabbitMQ when this playbook runs. You can also change # SSL certificate for RabbitMQ when this playbook runs. You can also change
# the subject of the self-signed certificate here if you prefer. # the subject of the self-signed certificate here if you prefer.
rabbitmq_ssl_self_signed_regen: false rabbitmq_ssl_self_signed_regen: false
rabbitmq_ssl_self_signed_subject: "/C=US/ST=Texas/L=San Antonio/O=IT/CN={{ ansible_hostname }}" rabbitmq_ssl_self_signed_subject: "/C=US/ST=Texas/L=San Antonio/O=IT/CN={{ ansible_facts['hostname'] }}"
# Define user-provided SSL certificates in: # Define user-provided SSL certificates in:
# /etc/openstack_deploy/user_variables.yml # /etc/openstack_deploy/user_variables.yml

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

View File

@ -36,11 +36,11 @@
command: | command: |
rabbitmqctl set_cluster_name {{ rabbitmq_cluster_name }} rabbitmqctl set_cluster_name {{ rabbitmq_cluster_name }}
when: when:
- "ansible_hostname == rabbitmq_primary_cluster_node" - "ansible_facts['hostname'] == rabbitmq_primary_cluster_node"
- "_cluster_name.stdout != rabbitmq_cluster_name" - "_cluster_name.stdout != rabbitmq_cluster_name"
- name: Join cluster on secondary nodes - name: Join cluster on secondary nodes
include_tasks: rabbitmq_cluster_join.yml include_tasks: rabbitmq_cluster_join.yml
when: when:
- "ansible_hostname != rabbitmq_primary_cluster_node" - "ansible_facts['hostname'] != rabbitmq_primary_cluster_node"
- "_cluster_name.stdout != rabbitmq_cluster_name" - "_cluster_name.stdout != rabbitmq_cluster_name"

View File

@ -15,7 +15,7 @@
- include_tasks: rabbitmq_upgrade_check.yml - include_tasks: rabbitmq_upgrade_check.yml
- include_tasks: "install_{{ ansible_pkg_mgr }}.yml" - include_tasks: "install_{{ ansible_facts['pkg_mgr'] }}.yml"
tags: tags:
- rabbitmq-apt-packages - rabbitmq-apt-packages
- rabbitmq-yum-packages - rabbitmq-yum-packages

View File

@ -79,7 +79,7 @@
- name: Apply rabbitmq policies - name: Apply rabbitmq policies
community.rabbitmq.rabbitmq_policy: community.rabbitmq.rabbitmq_policy:
node: "rabbit@{{ ansible_hostname }}" node: "rabbit@{{ ansible_facts['hostname'] }}"
name: "{{ item.name }}" name: "{{ item.name }}"
pattern: "{{ item.pattern }}" pattern: "{{ item.pattern }}"
priority: "{{ item.priority | default(0) }}" priority: "{{ item.priority | default(0) }}"
@ -100,7 +100,7 @@
# that the "guest" user is eradicated. # that the "guest" user is eradicated.
- name: Ensure default rabbitmq guest user is removed - name: Ensure default rabbitmq guest user is removed
community.rabbitmq.rabbitmq_user: community.rabbitmq.rabbitmq_user:
node: "rabbit@{{ ansible_hostname }}" node: "rabbit@{{ ansible_facts['hostname'] }}"
user: guest user: guest
state: absent state: absent
when: inventory_hostname == groups[rabbitmq_host_group][0] when: inventory_hostname == groups[rabbitmq_host_group][0]
@ -109,7 +109,7 @@
- name: Ensure default rabbitmq guest user is removed - name: Ensure default rabbitmq guest user is removed
community.rabbitmq.rabbitmq_user: community.rabbitmq.rabbitmq_user:
node: "rabbit@{{ ansible_hostname }}" node: "rabbit@{{ ansible_facts['hostname'] }}"
user: guest user: guest
state: absent state: absent
when: inventory_hostname != groups[rabbitmq_host_group][0] when: inventory_hostname != groups[rabbitmq_host_group][0]

View File

@ -19,7 +19,7 @@
state: started state: started
enabled: yes enabled: yes
when: when:
- ansible_hostname == rabbitmq_primary_cluster_node - ansible_facts['hostname'] == rabbitmq_primary_cluster_node
tags: tags:
- rabbitmq-server-started - rabbitmq-server-started
- rabbitmq-upgrade - rabbitmq-upgrade
@ -31,7 +31,7 @@
state: started state: started
enabled: yes enabled: yes
when: when:
- ansible_hostname != rabbitmq_primary_cluster_node - ansible_facts['hostname'] != rabbitmq_primary_cluster_node
tags: tags:
- rabbitmq-server-started - rabbitmq-server-started
- rabbitmq-upgrade - rabbitmq-upgrade

View File

@ -19,7 +19,7 @@
state: stopped state: stopped
failed_when: false failed_when: false
when: when:
- ansible_hostname != rabbitmq_primary_cluster_node - ansible_facts['hostname'] != rabbitmq_primary_cluster_node
tags: tags:
- rabbitmq-server-stopped - rabbitmq-server-stopped
- rabbitmq-upgrade - rabbitmq-upgrade
@ -31,7 +31,7 @@
state: stopped state: stopped
failed_when: false failed_when: false
when: when:
- ansible_hostname == rabbitmq_primary_cluster_node - ansible_facts['hostname'] == rabbitmq_primary_cluster_node
tags: tags:
- rabbitmq-server-stopped - rabbitmq-server-stopped
- rabbitmq-upgrade - rabbitmq-upgrade

View File

@ -23,7 +23,7 @@
register: installed_rabbitmq_deb register: installed_rabbitmq_deb
when: when:
- not rabbitmq_upgrade | bool - not rabbitmq_upgrade | bool
- ansible_pkg_mgr == 'apt' - ansible_facts['pkg_mgr'] == 'apt'
tags: tags:
- rabbitmq-package-deb - rabbitmq-package-deb
- rabbitmq-apt-packages - rabbitmq-apt-packages
@ -41,7 +41,7 @@
register: installed_rabbitmq_rpm register: installed_rabbitmq_rpm
when: when:
- not rabbitmq_upgrade | bool - not rabbitmq_upgrade | bool
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] - ansible_facts['pkg_mgr'] in ['yum', 'dnf', 'zypper']
tags: tags:
- rabbitmq-package-rpm - rabbitmq-package-rpm
- rabbitmq-yum-packages - rabbitmq-yum-packages

View File

@ -1,7 +1,7 @@
# {{ ansible_managed }} # {{ ansible_managed }}
# Set ERLANG VM parameters # Set ERLANG VM parameters
NODENAME=rabbit@{{ ansible_hostname }} NODENAME=rabbit@{{ ansible_facts['hostname'] }}
RABBITMQ_IO_THREAD_POOL_SIZE={{ rabbitmq_async_threads }} RABBITMQ_IO_THREAD_POOL_SIZE={{ rabbitmq_async_threads }}
RABBITMQ_SERVER_ERL_ARGS="+P {{ rabbitmq_process_limit }}" RABBITMQ_SERVER_ERL_ARGS="+P {{ rabbitmq_process_limit }}"

View File

@ -20,22 +20,22 @@ _rabbitmq_gpg_keys:
- file: gpg/4D206F89 - file: gpg/4D206F89
- file: gpg/A14F4FCA - file: gpg/A14F4FCA
_rabbitmq_repo_url: "https://packagecloud.io/rabbitmq/rabbitmq-server/{{ ansible_distribution | lower }}" _rabbitmq_repo_url: "https://packagecloud.io/rabbitmq/rabbitmq-server/{{ ansible_facts['distribution'] | lower }}"
_rabbitmq_repo: _rabbitmq_repo:
repo: "deb {{ rabbitmq_repo_url }} {{ ansible_distribution_release | lower }} main" repo: "deb {{ rabbitmq_repo_url }} {{ ansible_facts['distribution_release'] | lower }} main"
state: "present" state: "present"
filename: "RabbitMQ" filename: "RabbitMQ"
_rabbitmq_erlang_repo_url: "https://packages.erlang-solutions.com/{{ ansible_distribution | lower }}" _rabbitmq_erlang_repo_url: "https://packages.erlang-solutions.com/{{ ansible_facts['distribution'] | lower }}"
_rabbitmq_erlang_repo: _rabbitmq_erlang_repo:
repo: "deb {{ rabbitmq_erlang_repo_url }} {{ ansible_distribution_release | lower }} contrib" repo: "deb {{ rabbitmq_erlang_repo_url }} {{ ansible_facts['distribution_release'] | lower }} contrib"
state: "present" state: "present"
filename: els_erlang filename: els_erlang
_rabbitmq_erlang_version_spec: "{{ (rabbitmq_install_method == 'external_repo') | ternary('1:22.3-1', '1:22.*') }}" _rabbitmq_erlang_version_spec: "{{ (rabbitmq_install_method == 'external_repo') | ternary('1:22.3-1', '1:22.*') }}"
_rabbitmq_distro_dependencies: _rabbitmq_distro_dependencies:
- "{{ (ansible_architecture == 'aarch64') | ternary('erlang-base', 'erlang-base-hipe') }}" - "{{ (ansible_facts['architecture'] == 'aarch64') | ternary('erlang-base', 'erlang-base-hipe') }}"
- erlang-diameter - erlang-diameter
- erlang-eldap - erlang-eldap
- erlang-nox - erlang-nox

View File

@ -16,14 +16,14 @@
_rabbitmq_install_method: external_repo _rabbitmq_install_method: external_repo
_rabbitmq_package_version: 3.8.9-1 _rabbitmq_package_version: 3.8.9-1
_rabbitmq_repo_url: "https://packagecloud.io/rabbitmq/rabbitmq-server/el/{{ ansible_distribution_major_version }}/$basearch" _rabbitmq_repo_url: "https://packagecloud.io/rabbitmq/rabbitmq-server/el/{{ ansible_facts['distribution_major_version'] }}/$basearch"
_rabbitmq_repo: _rabbitmq_repo:
name: rabbitmq_rabbitmq-server name: rabbitmq_rabbitmq-server
description: "RabbitMQ Server Rolling Repository" description: "RabbitMQ Server Rolling Repository"
baseurl: "{{ rabbitmq_repo_url }}" baseurl: "{{ rabbitmq_repo_url }}"
filename: RabbitMQ filename: RabbitMQ
_rabbitmq_erlang_repo_url: "https://packagecloud.io/rabbitmq/erlang/el/{{ ansible_distribution_major_version }}/$basearch" _rabbitmq_erlang_repo_url: "https://packagecloud.io/rabbitmq/erlang/el/{{ ansible_facts['distribution_major_version'] }}/$basearch"
_rabbitmq_erlang_repo: _rabbitmq_erlang_repo:
name: rabbitmq_els-erlang name: rabbitmq_els-erlang
description: "RabbitMQ Erlang Packages from Bintray" description: "RabbitMQ Erlang Packages from Bintray"

View File

@ -15,7 +15,7 @@
# NOTE(jrosser) this is set to distro as there is no rabbitmq package currently for focal at packagecloud # NOTE(jrosser) this is set to distro as there is no rabbitmq package currently for focal at packagecloud
_rabbitmq_install_method: distro _rabbitmq_install_method: distro
_rabbitmq_package_url: "https://packagecloud.io/rabbitmq/rabbitmq-server/packages/{{ ansible_distribution | lower }}/{{ ansible_distribution_release | lower }}/rabbitmq-server_3.8.2-1_all.deb/download.deb" _rabbitmq_package_url: "https://packagecloud.io/rabbitmq/rabbitmq-server/packages/{{ ansible_facts['distribution'] | lower }}/{{ ansible_facts['distribution_release'] | lower }}/rabbitmq-server_3.8.2-1_all.deb/download.deb"
_rabbitmq_package_version: "{{ _rabbitmq_package_url.split('/')[-2].split('_')[1] }}" _rabbitmq_package_version: "{{ _rabbitmq_package_url.split('/')[-2].split('_')[1] }}"
_rabbitmq_release_version: "{{ _rabbitmq_package_version.split('-')[0] }}" _rabbitmq_release_version: "{{ _rabbitmq_package_version.split('-')[0] }}"
_rabbitmq_package_sha256: "aebdb80be49fe3adbf99c859006d8a503f531be79a0cd0712a30341e4c72054f" _rabbitmq_package_sha256: "aebdb80be49fe3adbf99c859006d8a503f531be79a0cd0712a30341e4c72054f"
@ -25,16 +25,16 @@ _rabbitmq_gpg_keys:
- file: gpg/4D206F89 - file: gpg/4D206F89
- file: gpg/A14F4FCA - file: gpg/A14F4FCA
_rabbitmq_repo_url: "https://packagecloud.io/rabbitmq/rabbitmq-server/{{ ansible_distribution | lower }}" _rabbitmq_repo_url: "https://packagecloud.io/rabbitmq/rabbitmq-server/{{ ansible_facts['distribution'] | lower }}"
_rabbitmq_repo: _rabbitmq_repo:
repo: "deb {{ rabbitmq_repo_url }} {{ ansible_distribution_release | lower }} main" repo: "deb {{ rabbitmq_repo_url }} {{ ansible_facts['distribution_release'] | lower }} main"
# NOTE(jrosser) this is set to absent as there is no rabbitmq package currently for focal at packagecloud # NOTE(jrosser) this is set to absent as there is no rabbitmq package currently for focal at packagecloud
state: "absent" state: "absent"
filename: "RabbitMQ" filename: "RabbitMQ"
_rabbitmq_erlang_repo_url: "https://packages.erlang-solutions.com/{{ ansible_distribution | lower }}" _rabbitmq_erlang_repo_url: "https://packages.erlang-solutions.com/{{ ansible_facts['distribution'] | lower }}"
_rabbitmq_erlang_repo: _rabbitmq_erlang_repo:
repo: "deb {{ rabbitmq_erlang_repo_url }} {{ ansible_distribution_release | lower }} contrib" repo: "deb {{ rabbitmq_erlang_repo_url }} {{ ansible_facts['distribution_release'] | lower }} contrib"
# NOTE(jrosser) this is set to absent as there is no erlang package currently for focal at packagecloud # NOTE(jrosser) this is set to absent as there is no erlang package currently for focal at packagecloud
state: "absent" state: "absent"
filename: els_erlang filename: els_erlang
@ -42,7 +42,7 @@ _rabbitmq_erlang_repo:
_rabbitmq_erlang_version_spec: "1:22.*" _rabbitmq_erlang_version_spec: "1:22.*"
rabbitmq_dependencies: rabbitmq_dependencies:
- "{{ (ansible_architecture == 'aarch64') | ternary('erlang-base', 'erlang-base-hipe') }}" - "{{ (ansible_facts['architecture'] == 'aarch64') | ternary('erlang-base', 'erlang-base-hipe') }}"
- erlang-diameter - erlang-diameter
- erlang-eldap - erlang-eldap
- erlang-nox - erlang-nox