aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md18
-rw-r--r--defaults/main.yml2
-rw-r--r--tasks/rabbitmq_clustering.yml23
3 files changed, 28 insertions, 15 deletions
diff --git a/README.md b/README.md
index 88f3c94..28b2b03 100644
--- a/README.md
+++ b/README.md
@@ -10,15 +10,11 @@ Any pre-requisites that may not be covered by Ansible itself or the role should
10 10
11Role Variables 11Role Variables
12-------------- 12--------------
13define in one host_vars/host config to designate the master_rabbit_node
14````
15master_rabbit_node: true
16````
17 13
18```` 14````
19enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
20config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group 15config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group
21master_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 16enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
17erlang_cookie: LSKNKBELKPSTDBBCHETL #define erlang cookie for cluster...define here or in group_vars/group
22rabbitmq_config: 18rabbitmq_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'
25rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group
26````
27
28example...
29group_vars/rabbitmq-cluster-nodes
30````
31---
32enable_rabbitmq_clustering: true
33config_rabbitmq_ha: false
34rabbitmq_master: ans-test-1
29```` 35````
30 36
31Dependencies 37Dependencies
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 @@
3config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group 3config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group
4enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group 4enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
5erlang_cookie: LSKNKBELKPSTDBBCHETL #define erlang cookie for cluster...define here or in group_vars/group 5erlang_cookie: LSKNKBELKPSTDBBCHETL #define erlang cookie for cluster...define here or in group_vars/group
6master_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
7rabbitmq_config: 6rabbitmq_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'
13rabbitmq_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