diff --git a/defaults/main.yml b/defaults/main.yml index 42323bee..647ff56d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -16,7 +16,7 @@ ## APT Cache Options cache_timeout: 600 -rabbitmq_primary_cluster_node: "{{ groups['rabbitmq_all'][0] }}" +rabbitmq_primary_cluster_node: "{{ hostvars[groups['rabbitmq_all'][0]]['ansible_hostname'] }}" # Upgrading the RabbitMQ package requires shutting down the cluster. This variable makes upgrading # the version an explicit action. diff --git a/tasks/rabbitmq_cluster.yml b/tasks/rabbitmq_cluster.yml index bac42460..0bac7842 100644 --- a/tasks/rabbitmq_cluster.yml +++ b/tasks/rabbitmq_cluster.yml @@ -15,8 +15,8 @@ - include: rabbitmq_cluster_create.yml when: > - inventory_hostname == rabbitmq_primary_cluster_node + ansible_hostname == rabbitmq_primary_cluster_node - include: rabbitmq_cluster_join.yml when: > - inventory_hostname != rabbitmq_primary_cluster_node + ansible_hostname != rabbitmq_primary_cluster_node diff --git a/tasks/rabbitmq_started.yml b/tasks/rabbitmq_started.yml index 0bbef5dc..f76369fc 100644 --- a/tasks/rabbitmq_started.yml +++ b/tasks/rabbitmq_started.yml @@ -19,7 +19,7 @@ state: started failed_when: false when: > - inventory_hostname == rabbitmq_primary_cluster_node + ansible_hostname == rabbitmq_primary_cluster_node tags: - rabbitmq-server-started - rabbitmq-upgrade @@ -31,7 +31,7 @@ state: started failed_when: false when: > - inventory_hostname != rabbitmq_primary_cluster_node + ansible_hostname != rabbitmq_primary_cluster_node tags: - rabbitmq-server-started - rabbitmq-upgrade diff --git a/tasks/rabbitmq_stopped.yml b/tasks/rabbitmq_stopped.yml index 404c9ead..cbc75f4e 100644 --- a/tasks/rabbitmq_stopped.yml +++ b/tasks/rabbitmq_stopped.yml @@ -19,7 +19,7 @@ state: stopped failed_when: false when: > - inventory_hostname != rabbitmq_primary_cluster_node + ansible_hostname != rabbitmq_primary_cluster_node tags: - rabbitmq-server-stopped - rabbitmq-upgrade @@ -31,7 +31,7 @@ state: stopped failed_when: false when: > - inventory_hostname == rabbitmq_primary_cluster_node + ansible_hostname == rabbitmq_primary_cluster_node tags: - rabbitmq-server-stopped - rabbitmq-upgrade