summaryrefslogtreecommitdiffstats
path: root/deploy/adapters
diff options
context:
space:
mode:
authorcarey.xu <carey.xuhan@huawei.com>2016-03-01 16:44:00 +0800
committercarey.xu <carey.xuhan@huawei.com>2016-03-09 11:07:13 +0800
commit1ef196baddbe5d681ac10ee23e01c5f0ac8bed79 (patch)
tree16cd6496e35e3611a2410d9b56015a6946af132e /deploy/adapters
parent77d64aa555766419280019f0e66bcf6d6cd70a7a (diff)
maker rabbitmq playbook reentrant
JIRA: COMPASS-328 Change-Id: Ia859db4f995ffac4cf01ab74da17f51c5d84dd1f Signed-off-by: carey.xu <carey.xuhan@huawei.com>
Diffstat (limited to 'deploy/adapters')
-rw-r--r--deploy/adapters/ansible/roles/mq/tasks/rabbitmq_cluster.yml17
-rwxr-xr-xdeploy/adapters/ansible/roles/mq/tasks/rabbitmq_install.yml15
2 files changed, 31 insertions, 1 deletions
diff --git a/deploy/adapters/ansible/roles/mq/tasks/rabbitmq_cluster.yml b/deploy/adapters/ansible/roles/mq/tasks/rabbitmq_cluster.yml
index a84cbeda..50c062f5 100644
--- a/deploy/adapters/ansible/roles/mq/tasks/rabbitmq_cluster.yml
+++ b/deploy/adapters/ansible/roles/mq/tasks/rabbitmq_cluster.yml
@@ -7,15 +7,30 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---
+- name: check if i in the node list
+ shell: |
+ rabbitmqctl -q cluster_status | grep '\[{nodes,'|grep {{ inventory_hostname }}
+ changed_when: is_member.rc != 0
+ failed_when: false
+ register: is_member
+ delegate_to: '{{ haproxy_hosts.keys()[0] }}'
+
- name: stop rabbitmq app
- shell: rabbitmqctl stop_app; sleep 3
+ shell: |
+ rabbitmqctl stop_app; sleep 5
+ failed_when: false
+ when: is_member.rc != 0
- name: join cluster
shell: rabbitmqctl join_cluster rabbit@{{ haproxy_hosts.keys()[0] }}
register: join_result
+ when: is_member.rc != 0
until: join_result|success
+ failed_when: join_result|failed and not 'already_member' in join_result.stderr
+ changed_when: join_result|success
retries: 20
delay: 3
- name: start rabbitmq app
shell: rabbitmqctl start_app
+ when: is_member.rc != 0
diff --git a/deploy/adapters/ansible/roles/mq/tasks/rabbitmq_install.yml b/deploy/adapters/ansible/roles/mq/tasks/rabbitmq_install.yml
index 067e240e..1c8c2fe7 100755
--- a/deploy/adapters/ansible/roles/mq/tasks/rabbitmq_install.yml
+++ b/deploy/adapters/ansible/roles/mq/tasks/rabbitmq_install.yml
@@ -68,6 +68,21 @@
pattern: '^(?!amq\.).*'
tags: "ha-mode=all"
+- name: get cluster name
+ shell: |
+ rabbitmqctl cluster_status | grep -w '<<"compass">>'
+ register: cluster_status
+ failed_when: false
+ changed_when: cluster_status.rc != 0
+ when: |
+ inventory_hostname == haproxy_hosts.keys()[0]
+
+- name: set cluster name
+ shell: rabbitmqctl set_cluster_name compass
+ when: |
+ inventory_hostname == haproxy_hosts.keys()[0]
+ and cluster_status.rc != 0
+
- include: rabbitmq_cluster.yml
when: inventory_hostname != haproxy_hosts.keys()[0]