# defaults file for ansible-rabbitmq
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
+#erlang_cookie: #define erlang cookie for cluster...define here or in group_vars/group
+erlang_cookie_file: /var/lib/rabbitmq/.erlang.cookie
rabbitmq_config:
- queue_name: logstash
durable: true
- name: rabbitmq_clustering | stopping rabbitmq-server
service: name=rabbitmq-server state=stopped
+- name: grabbing erlang cookie
+ shell: cat /var/lib/rabbitmq/.erlang.cookie
+ register: erlang_cookie
+ when: inventory_hostname == "{{ rabbitmq_master }}"
+
- 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
+ template: src=erlang.cookie.j2 dest={{ erlang_cookie_file }} owner=rabbitmq group=rabbitmq mode=0400 backup=yes
+ when: inventory_hostname != "{{ rabbitmq_master }}"
- name: rabbitmq_clustering | restarting rabbitmq-server on master
service: name=rabbitmq-server state=restarted