diff options
Diffstat (limited to 'deploy/adapters/ansible')
-rw-r--r-- | deploy/adapters/ansible/roles/mq/tasks/rabbitmq_cluster.yml | 17 | ||||
-rwxr-xr-x | deploy/adapters/ansible/roles/mq/tasks/rabbitmq_install.yml | 15 |
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] |