Role Variables
--------------
-define in one host_vars/host config to designate the master_rabbit_node
-````
-master_rabbit_node: true
-````
````
-enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group
-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
+enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
+erlang_cookie: LSKNKBELKPSTDBBCHETL #define erlang cookie for cluster...define here or in group_vars/group
rabbitmq_config:
- queue_name: logstash
durable: true
type: fanout
routing_key: logstash
tags: 'ha-mode=all,ha-sync-mode=automatic'
+rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group
+````
+
+example...
+group_vars/rabbitmq-cluster-nodes
+````
+---
+enable_rabbitmq_clustering: true
+config_rabbitmq_ha: false
+rabbitmq_master: ans-test-1
````
Dependencies
config_rabbitmq_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group
enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
erlang_cookie: LSKNKBELKPSTDBBCHETL #define erlang cookie for cluster...define here or in group_vars/group
-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
rabbitmq_config:
- queue_name: logstash
durable: true
type: fanout
routing_key: logstash
tags: 'ha-mode=all,ha-sync-mode=automatic'
+rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group
- name: rabbitmq_clustering | resetting rabbitmq app
command: rabbitmqctl reset
+- name: rabbitmq_clustering | stopping rabbitmq-server
+ service: name=rabbitmq-server state=stopped
+
- name: rabbitmq_clustering | copy erlang cookie
template: src=erlang.cookie.j2 dest=/var/lib/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400 backup=yes
-- name: rabbitmq_clustering | starting rabbitmq app
+- name: rabbitmq_clustering | restarting rabbitmq-server on master
+ service: name=rabbitmq-server state=restarted
+ when: inventory_hostname == "{{ rabbitmq_master }}"
+
+- name: rabbitmq_clustering | starting rabbitmq app on master
command: rabbitmqctl start_app
register: cluster_master
- when: master_rabbit_node is defined and master_rabbit_node
+ when: inventory_hostname == "{{ rabbitmq_master }}"
- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes
shell: pkill -u rabbitmq || true
- when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed
+ when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed
- name: rabbitmq_clustering | restarting rabbitmq-server
service: name=rabbitmq-server state=restarted
- when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed
+ when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed
- name: rabbitmq_clustering | stopping rabbitmq app
command: rabbitmqctl stop_app
- when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed
+ when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed
- name: rabbitmq_clustering | resetting rabbitmq app
command: rabbitmqctl reset
- when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed
+ when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed
- name: rabbitmq_clustering | joining rabbitmq cluster
command: rabbitmqctl join_cluster 'rabbit@{{ master_rabbit_node }}'
- when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed
+ when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed
- name: rabbitmq_clustering | starting rabbitmq app
command: rabbitmqctl start_app
- when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed
+ when: inventory_hostname != "{{ rabbitmq_master }}" and cluster_master.changed
- name: rabbitmq_clustering | marking as clustered
file: path=/etc/rabbitmq/clustered state=touch