diff options
Diffstat (limited to 'tasks/rabbitmq_clustering.yml')
-rw-r--r-- | tasks/rabbitmq_clustering.yml | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml new file mode 100644 index 0000000..9dece46 --- /dev/null +++ b/tasks/rabbitmq_clustering.yml | |||
@@ -0,0 +1,70 @@ | |||
1 | --- | ||
2 | - name: rabbitmq_clustering | stopping rabbitmq app | ||
3 | command: rabbitmqctl stop_app | ||
4 | |||
5 | - name: rabbitmq_clustering | resetting rabbitmq app | ||
6 | command: rabbitmqctl reset | ||
7 | |||
8 | - name: rabbitmq_clustering | stopping rabbitmq-server | ||
9 | service: | ||
10 | name: rabbitmq-server | ||
11 | state: stopped | ||
12 | |||
13 | #- name: grabbing erlang cookie | ||
14 | # shell: cat /var/lib/rabbitmq/.erlang.cookie | ||
15 | # register: rabbitmq_erlang_cookie | ||
16 | # when: inventory_hostname == "{{ rabbitmq_master }}" | ||
17 | |||
18 | - name: rabbitmq_clustering | copy erlang cookie | ||
19 | template: | ||
20 | src: erlang.cookie.j2 | ||
21 | dest: "{{ rabbitmq_erlang_cookie_file }}" | ||
22 | owner: rabbitmq | ||
23 | group: rabbitmq | ||
24 | mode: 0400 | ||
25 | backup: yes #backing up in case the need to recover | ||
26 | # when: inventory_hostname != "{{ rabbitmq_master }}" | ||
27 | |||
28 | - name: rabbitmq_clustering | restarting rabbitmq-server on master | ||
29 | service: | ||
30 | name: rabbitmq-server | ||
31 | state: restarted | ||
32 | when: inventory_hostname == "{{ rabbitmq_master }}" | ||
33 | |||
34 | - name: rabbitmq_clustering | starting rabbitmq app on master | ||
35 | command: rabbitmqctl start_app | ||
36 | register: cluster_master | ||
37 | when: inventory_hostname == "{{ rabbitmq_master }}" | ||
38 | |||
39 | - name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes | ||
40 | shell: pkill -u rabbitmq || true | ||
41 | when: inventory_hostname != "{{ rabbitmq_master }}" | ||
42 | |||
43 | - name: rabbitmq_clustering | restarting rabbitmq-server | ||
44 | service: | ||
45 | name: rabbitmq-server | ||
46 | state: restarted | ||
47 | when: inventory_hostname != "{{ rabbitmq_master }}" | ||
48 | |||
49 | - name: rabbitmq_clustering | stopping rabbitmq app | ||
50 | command: rabbitmqctl stop_app | ||
51 | when: inventory_hostname != "{{ rabbitmq_master }}" | ||
52 | |||
53 | - name: rabbitmq_clustering | resetting rabbitmq app | ||
54 | command: rabbitmqctl reset | ||
55 | when: inventory_hostname != "{{ rabbitmq_master }}" | ||
56 | |||
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 }}" | ||
61 | |||
62 | - name: rabbitmq_clustering | starting rabbitmq app | ||
63 | command: rabbitmqctl start_app | ||
64 | when: inventory_hostname != "{{ rabbitmq_master }}" | ||
65 | |||
66 | - name: rabbitmq_clustering | marking as clustered | ||
67 | file: | ||
68 | path: /etc/rabbitmq/clustered | ||
69 | state: touch | ||
70 | when: cluster_master.changed or cluster_joined.changed | ||