diff options
-rw-r--r-- | README.md | 18 | ||||
-rw-r--r-- | defaults/main.yml | 2 | ||||
-rw-r--r-- | tasks/rabbitmq_clustering.yml | 23 |
3 files changed, 28 insertions, 15 deletions
@@ -10,15 +10,11 @@ Any pre-requisites that may not be covered by Ansible itself or the role should | |||
10 | 10 | ||
11 | Role Variables | 11 | Role Variables |
12 | -------------- | 12 | -------------- |
13 | define in one host_vars/host config to designate the master_rabbit_node | ||
14 | ```` | ||
15 | master_rabbit_node: true | ||
16 | ```` | ||
17 | 13 | ||
18 | ```` | 14 | ```` |
19 | enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group | ||
20 | config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group | 15 | config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group |
21 | master_rabbit_node: false #defines if node should be considered master...define as true in one host in host_vars/host out of all nodes to be part of cluster | 16 | enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group |
17 | erlang_cookie: LSKNKBELKPSTDBBCHETL #define erlang cookie for cluster...define here or in group_vars/group | ||
22 | rabbitmq_config: | 18 | rabbitmq_config: |
23 | - queue_name: logstash | 19 | - queue_name: logstash |
24 | durable: true | 20 | durable: true |
@@ -26,6 +22,16 @@ rabbitmq_config: | |||
26 | type: fanout | 22 | type: fanout |
27 | routing_key: logstash | 23 | routing_key: logstash |
28 | tags: 'ha-mode=all,ha-sync-mode=automatic' | 24 | tags: 'ha-mode=all,ha-sync-mode=automatic' |
25 | rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group | ||
26 | ```` | ||
27 | |||
28 | example... | ||
29 | group_vars/rabbitmq-cluster-nodes | ||
30 | ```` | ||
31 | --- | ||
32 | enable_rabbitmq_clustering: true | ||
33 | config_rabbitmq_ha: false | ||
34 | rabbitmq_master: ans-test-1 | ||
29 | ```` | 35 | ```` |
30 | 36 | ||
31 | Dependencies | 37 | Dependencies |
diff --git a/defaults/main.yml b/defaults/main.yml index 95caff5..2c7ea69 100644 --- a/defaults/main.yml +++ b/defaults/main.yml | |||
@@ -3,7 +3,6 @@ | |||
3 | config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group | 3 | config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group |
4 | enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group | 4 | enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group |
5 | erlang_cookie: LSKNKBELKPSTDBBCHETL #define erlang cookie for cluster...define here or in group_vars/group | 5 | erlang_cookie: LSKNKBELKPSTDBBCHETL #define erlang cookie for cluster...define here or in group_vars/group |
6 | master_rabbit_node: false #defines if node should be considered master...define as true in one host in host_vars/host out of all nodes to be part of cluster | ||
7 | rabbitmq_config: | 6 | rabbitmq_config: |
8 | - queue_name: logstash | 7 | - queue_name: logstash |
9 | durable: true | 8 | durable: true |
@@ -11,3 +10,4 @@ rabbitmq_config: | |||
11 | type: fanout | 10 | type: fanout |
12 | routing_key: logstash | 11 | routing_key: logstash |
13 | tags: 'ha-mode=all,ha-sync-mode=automatic' | 12 | tags: 'ha-mode=all,ha-sync-mode=automatic' |
13 | rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group | ||
diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml index a34ff92..a87bb2b 100644 --- a/tasks/rabbitmq_clustering.yml +++ b/tasks/rabbitmq_clustering.yml | |||
@@ -5,37 +5,44 @@ | |||
5 | - name: rabbitmq_clustering | resetting rabbitmq app | 5 | - name: rabbitmq_clustering | resetting rabbitmq app |
6 | command: rabbitmqctl reset | 6 | command: rabbitmqctl reset |
7 | 7 | ||
8 | - name: rabbitmq_clustering | stopping rabbitmq-server | ||
9 | service: name=rabbitmq-server state=stopped | ||
10 | |||
8 | - name: rabbitmq_clustering | copy erlang cookie | 11 | - name: rabbitmq_clustering | copy erlang cookie |
9 | template: src=erlang.cookie.j2 dest=/var/lib/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400 backup=yes | 12 | template: src=erlang.cookie.j2 dest=/var/lib/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400 backup=yes |
10 | 13 | ||
11 | - name: rabbitmq_clustering | starting rabbitmq app | 14 | - name: rabbitmq_clustering | restarting rabbitmq-server on master |
15 | service: name=rabbitmq-server state=restarted | ||
16 | when: inventory_hostname == "{{ rabbitmq_master }}" | ||
17 | |||
18 | - name: rabbitmq_clustering | starting rabbitmq app on master | ||
12 | command: rabbitmqctl start_app | 19 | command: rabbitmqctl start_app |
13 | register: cluster_master | 20 | register: cluster_master |
14 | when: master_rabbit_node is defined and master_rabbit_node | 21 | when: inventory_hostname == "{{ rabbitmq_master }}" |
15 | 22 | ||
16 | - name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes | 23 | - name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes |
17 | shell: pkill -u rabbitmq || true | 24 | shell: pkill -u rabbitmq || true |
18 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed | 25 | when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed |
19 | 26 | ||
20 | - name: rabbitmq_clustering | restarting rabbitmq-server | 27 | - name: rabbitmq_clustering | restarting rabbitmq-server |
21 | service: name=rabbitmq-server state=restarted | 28 | service: name=rabbitmq-server state=restarted |
22 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed | 29 | when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed |
23 | 30 | ||
24 | - name: rabbitmq_clustering | stopping rabbitmq app | 31 | - name: rabbitmq_clustering | stopping rabbitmq app |
25 | command: rabbitmqctl stop_app | 32 | command: rabbitmqctl stop_app |
26 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed | 33 | when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed |
27 | 34 | ||
28 | - name: rabbitmq_clustering | resetting rabbitmq app | 35 | - name: rabbitmq_clustering | resetting rabbitmq app |
29 | command: rabbitmqctl reset | 36 | command: rabbitmqctl reset |
30 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed | 37 | when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed |
31 | 38 | ||
32 | - name: rabbitmq_clustering | joining rabbitmq cluster | 39 | - name: rabbitmq_clustering | joining rabbitmq cluster |
33 | command: rabbitmqctl join_cluster 'rabbit@{{ master_rabbit_node }}' | 40 | command: rabbitmqctl join_cluster 'rabbit@{{ master_rabbit_node }}' |
34 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed | 41 | when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed |
35 | 42 | ||
36 | - name: rabbitmq_clustering | starting rabbitmq app | 43 | - name: rabbitmq_clustering | starting rabbitmq app |
37 | command: rabbitmqctl start_app | 44 | command: rabbitmqctl start_app |
38 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed | 45 | when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed |
39 | 46 | ||
40 | - name: rabbitmq_clustering | marking as clustered | 47 | - name: rabbitmq_clustering | marking as clustered |
41 | file: path=/etc/rabbitmq/clustered state=touch | 48 | file: path=/etc/rabbitmq/clustered state=touch |