2 - name: rabbitmq_clustering | stopping rabbitmq app
3 command: rabbitmqctl stop_app
5 - name: rabbitmq_clustering | resetting rabbitmq app
6 command: rabbitmqctl reset
8 - name: rabbitmq_clustering | stopping rabbitmq-server
13 #- name: grabbing erlang cookie
14 # shell: cat /var/lib/rabbitmq/.erlang.cookie
15 # register: rabbitmq_erlang_cookie
16 # when: inventory_hostname == "{{ rabbitmq_master }}"
18 - name: rabbitmq_clustering | copy erlang cookie
21 dest: "{{ rabbitmq_erlang_cookie_file }}"
25 backup: yes #backing up in case the need to recover
26 # when: inventory_hostname != "{{ rabbitmq_master }}"
28 - name: rabbitmq_clustering | restarting rabbitmq-server on master
32 when: inventory_hostname == "{{ rabbitmq_master }}"
34 - name: rabbitmq_clustering | starting rabbitmq app on master
35 command: rabbitmqctl start_app
36 register: cluster_master
37 when: inventory_hostname == "{{ rabbitmq_master }}"
39 - name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes
40 shell: pkill -u rabbitmq || true
41 when: inventory_hostname != "{{ rabbitmq_master }}"
43 - name: rabbitmq_clustering | restarting rabbitmq-server
47 when: inventory_hostname != "{{ rabbitmq_master }}"
49 - name: rabbitmq_clustering | stopping rabbitmq app
50 command: rabbitmqctl stop_app
51 when: inventory_hostname != "{{ rabbitmq_master }}"
53 - name: rabbitmq_clustering | resetting rabbitmq app
54 command: rabbitmqctl reset
55 when: inventory_hostname != "{{ rabbitmq_master }}"
57 - name: rabbitmq_clustering | joining rabbitmq cluster
58 command: rabbitmqctl join_cluster 'rabbit@{{ rabbitmq_master }}'
59 register: cluster_joined
60 when: inventory_hostname != "{{ rabbitmq_master }}"
62 - name: rabbitmq_clustering | starting rabbitmq app
63 command: rabbitmqctl start_app
64 when: inventory_hostname != "{{ rabbitmq_master }}"
66 - name: rabbitmq_clustering | marking as clustered
68 path: /etc/rabbitmq/clustered
70 when: cluster_master.changed or cluster_joined.changed