diff --git a/defaults/main.yml b/defaults/main.yml index adb9fe84..01d1ca58 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -34,11 +34,11 @@ rabbit_system_group_name: rabbitmq rabbitmq_hosts_entries: >- {{ groups[rabbitmq_host_group] | map('extract', hostvars) | list | 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 # 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 # the subject of the self-signed certificate here if you prefer. 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: # /etc/openstack_deploy/user_variables.yml diff --git a/tasks/main.yml b/tasks/main.yml index e5f3cfaf..2b7dd2da 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,11 +16,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/rabbitmq_cluster.yml b/tasks/rabbitmq_cluster.yml index 77e13b09..18cf56df 100644 --- a/tasks/rabbitmq_cluster.yml +++ b/tasks/rabbitmq_cluster.yml @@ -36,11 +36,11 @@ command: | rabbitmqctl set_cluster_name {{ rabbitmq_cluster_name }} when: - - "ansible_hostname == rabbitmq_primary_cluster_node" + - "ansible_facts['hostname'] == rabbitmq_primary_cluster_node" - "_cluster_name.stdout != rabbitmq_cluster_name" - name: Join cluster on secondary nodes include_tasks: rabbitmq_cluster_join.yml when: - - "ansible_hostname != rabbitmq_primary_cluster_node" + - "ansible_facts['hostname'] != rabbitmq_primary_cluster_node" - "_cluster_name.stdout != rabbitmq_cluster_name" diff --git a/tasks/rabbitmq_install.yml b/tasks/rabbitmq_install.yml index fc2f533c..05f9f4e5 100644 --- a/tasks/rabbitmq_install.yml +++ b/tasks/rabbitmq_install.yml @@ -15,7 +15,7 @@ - include_tasks: rabbitmq_upgrade_check.yml -- include_tasks: "install_{{ ansible_pkg_mgr }}.yml" +- include_tasks: "install_{{ ansible_facts['pkg_mgr'] }}.yml" tags: - rabbitmq-apt-packages - rabbitmq-yum-packages diff --git a/tasks/rabbitmq_post_install.yml b/tasks/rabbitmq_post_install.yml index 3331be66..4f45a60e 100644 --- a/tasks/rabbitmq_post_install.yml +++ b/tasks/rabbitmq_post_install.yml @@ -79,7 +79,7 @@ - name: Apply rabbitmq policies community.rabbitmq.rabbitmq_policy: - node: "rabbit@{{ ansible_hostname }}" + node: "rabbit@{{ ansible_facts['hostname'] }}" name: "{{ item.name }}" pattern: "{{ item.pattern }}" priority: "{{ item.priority | default(0) }}" @@ -100,7 +100,7 @@ # that the "guest" user is eradicated. - name: Ensure default rabbitmq guest user is removed community.rabbitmq.rabbitmq_user: - node: "rabbit@{{ ansible_hostname }}" + node: "rabbit@{{ ansible_facts['hostname'] }}" user: guest state: absent when: inventory_hostname == groups[rabbitmq_host_group][0] @@ -109,7 +109,7 @@ - name: Ensure default rabbitmq guest user is removed community.rabbitmq.rabbitmq_user: - node: "rabbit@{{ ansible_hostname }}" + node: "rabbit@{{ ansible_facts['hostname'] }}" user: guest state: absent when: inventory_hostname != groups[rabbitmq_host_group][0] diff --git a/tasks/rabbitmq_started.yml b/tasks/rabbitmq_started.yml index ac23a7e4..41fe9872 100644 --- a/tasks/rabbitmq_started.yml +++ b/tasks/rabbitmq_started.yml @@ -19,7 +19,7 @@ state: started enabled: yes when: - - ansible_hostname == rabbitmq_primary_cluster_node + - ansible_facts['hostname'] == rabbitmq_primary_cluster_node tags: - rabbitmq-server-started - rabbitmq-upgrade @@ -31,7 +31,7 @@ state: started enabled: yes when: - - ansible_hostname != rabbitmq_primary_cluster_node + - ansible_facts['hostname'] != rabbitmq_primary_cluster_node tags: - rabbitmq-server-started - rabbitmq-upgrade diff --git a/tasks/rabbitmq_stopped.yml b/tasks/rabbitmq_stopped.yml index ff900afa..e19e36c8 100644 --- a/tasks/rabbitmq_stopped.yml +++ b/tasks/rabbitmq_stopped.yml @@ -19,7 +19,7 @@ state: stopped failed_when: false when: - - ansible_hostname != rabbitmq_primary_cluster_node + - ansible_facts['hostname'] != rabbitmq_primary_cluster_node tags: - rabbitmq-server-stopped - rabbitmq-upgrade @@ -31,7 +31,7 @@ state: stopped failed_when: false when: - - ansible_hostname == rabbitmq_primary_cluster_node + - ansible_facts['hostname'] == rabbitmq_primary_cluster_node tags: - rabbitmq-server-stopped - rabbitmq-upgrade diff --git a/tasks/rabbitmq_upgrade_check.yml b/tasks/rabbitmq_upgrade_check.yml index dc499323..4afae0cd 100644 --- a/tasks/rabbitmq_upgrade_check.yml +++ b/tasks/rabbitmq_upgrade_check.yml @@ -23,7 +23,7 @@ register: installed_rabbitmq_deb when: - not rabbitmq_upgrade | bool - - ansible_pkg_mgr == 'apt' + - ansible_facts['pkg_mgr'] == 'apt' tags: - rabbitmq-package-deb - rabbitmq-apt-packages @@ -41,7 +41,7 @@ register: installed_rabbitmq_rpm when: - not rabbitmq_upgrade | bool - - ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] + - ansible_facts['pkg_mgr'] in ['yum', 'dnf', 'zypper'] tags: - rabbitmq-package-rpm - rabbitmq-yum-packages diff --git a/templates/rabbitmq-env.j2 b/templates/rabbitmq-env.j2 index 1ffe4368..93d58d1f 100644 --- a/templates/rabbitmq-env.j2 +++ b/templates/rabbitmq-env.j2 @@ -1,7 +1,7 @@ # {{ ansible_managed }} # Set ERLANG VM parameters -NODENAME=rabbit@{{ ansible_hostname }} +NODENAME=rabbit@{{ ansible_facts['hostname'] }} RABBITMQ_IO_THREAD_POOL_SIZE={{ rabbitmq_async_threads }} RABBITMQ_SERVER_ERL_ARGS="+P {{ rabbitmq_process_limit }}" diff --git a/vars/debian.yml b/vars/debian.yml index 79eeef53..67d6d6af 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -20,22 +20,22 @@ _rabbitmq_gpg_keys: - file: gpg/4D206F89 - 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: - repo: "deb {{ rabbitmq_repo_url }} {{ ansible_distribution_release | lower }} main" + repo: "deb {{ rabbitmq_repo_url }} {{ ansible_facts['distribution_release'] | lower }} main" state: "present" 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: - 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" filename: els_erlang _rabbitmq_erlang_version_spec: "{{ (rabbitmq_install_method == 'external_repo') | ternary('1:22.3-1', '1:22.*') }}" _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-eldap - erlang-nox diff --git a/vars/redhat.yml b/vars/redhat.yml index 239d10b0..5d82372b 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -16,14 +16,14 @@ _rabbitmq_install_method: external_repo _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: name: rabbitmq_rabbitmq-server description: "RabbitMQ Server Rolling Repository" baseurl: "{{ rabbitmq_repo_url }}" 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: name: rabbitmq_els-erlang description: "RabbitMQ Erlang Packages from Bintray" diff --git a/vars/ubuntu-20.04.yml b/vars/ubuntu-20.04.yml index 1e2ec246..109efafe 100644 --- a/vars/ubuntu-20.04.yml +++ b/vars/ubuntu-20.04.yml @@ -15,7 +15,7 @@ # NOTE(jrosser) this is set to distro as there is no rabbitmq package currently for focal at packagecloud _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_release_version: "{{ _rabbitmq_package_version.split('-')[0] }}" _rabbitmq_package_sha256: "aebdb80be49fe3adbf99c859006d8a503f531be79a0cd0712a30341e4c72054f" @@ -25,16 +25,16 @@ _rabbitmq_gpg_keys: - file: gpg/4D206F89 - 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: - 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 state: "absent" 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: - 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 state: "absent" filename: els_erlang @@ -42,7 +42,7 @@ _rabbitmq_erlang_repo: _rabbitmq_erlang_version_spec: "1:22.*" rabbitmq_dependencies: - - "{{ (ansible_architecture == 'aarch64') | ternary('erlang-base', 'erlang-base-hipe') }}" + - "{{ (ansible_facts['architecture'] == 'aarch64') | ternary('erlang-base', 'erlang-base-hipe') }}" - erlang-diameter - erlang-eldap - erlang-nox