openstack-ansible-rabbitmq_.../tasks/rabbitmq_cluster.yml
Dmitriy Rabotyagov d8d98a4e42 Use rabbitmq_cluster_state task instead of command
We can simplify logic and re-use rabbitmq_cluster_state tasks to
fetch the current state of the cluster in a dictionary, which allows
to avoid unnecessary today parsing of rabbitmq output.

Change-Id: Ib99fcb1a3e0092bf96143435a0c876ab6f286f36
2024-11-05 15:05:02 +00:00

31 lines
1.2 KiB
YAML

---
# Copyright 2014, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Importing rabbitmq_cluster_state tasks
import_tasks: rabbitmq_cluster_state.yml
- name: Set rabbitmq cluster name on primary node # noqa: no-changed-when
command: |
rabbitmqctl set_cluster_name {{ rabbitmq_cluster_name }}
when:
- "ansible_facts['hostname'] == rabbitmq_primary_cluster_node"
- "_cluster_state.get('cluster_name') != rabbitmq_cluster_name"
- name: Join cluster on secondary nodes
include_tasks: rabbitmq_cluster_join.yml
when:
- "ansible_facts['hostname'] != rabbitmq_primary_cluster_node"
- "_cluster_state.get('cluster_name') != rabbitmq_cluster_name"