From 109c6b750751d1c5cd216ad2f09258cf512c4c9e Mon Sep 17 00:00:00 2001 From: Larry Smith Jr Date: Sat, 3 Dec 2016 17:51:25 -0500 Subject: Addressed issue #6 Signed-off-by: Larry Smith Jr --- .../ansible-rabbitmq/tasks/rabbitmq_clustering.yml | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml (limited to 'Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml') diff --git a/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml b/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml new file mode 100644 index 0000000..9dece46 --- /dev/null +++ b/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml @@ -0,0 +1,70 @@ +--- +- name: rabbitmq_clustering | stopping rabbitmq app + command: rabbitmqctl stop_app + +- name: rabbitmq_clustering | resetting rabbitmq app + command: rabbitmqctl reset + +- name: rabbitmq_clustering | stopping rabbitmq-server + service: + name: rabbitmq-server + state: stopped + +#- name: grabbing erlang cookie +# shell: cat /var/lib/rabbitmq/.erlang.cookie +# register: rabbitmq_erlang_cookie +# when: inventory_hostname == "{{ rabbitmq_master }}" + +- name: rabbitmq_clustering | copy erlang cookie + template: + src: erlang.cookie.j2 + dest: "{{ rabbitmq_erlang_cookie_file }}" + owner: rabbitmq + group: rabbitmq + mode: 0400 + backup: yes #backing up in case the need to recover +# when: inventory_hostname != "{{ rabbitmq_master }}" + +- 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: inventory_hostname == "{{ rabbitmq_master }}" + +- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes + shell: pkill -u rabbitmq || true + when: inventory_hostname != "{{ rabbitmq_master }}" + +- name: rabbitmq_clustering | restarting rabbitmq-server + service: + name: rabbitmq-server + state: restarted + when: inventory_hostname != "{{ rabbitmq_master }}" + +- name: rabbitmq_clustering | stopping rabbitmq app + command: rabbitmqctl stop_app + when: inventory_hostname != "{{ rabbitmq_master }}" + +- name: rabbitmq_clustering | resetting rabbitmq app + command: rabbitmqctl reset + when: inventory_hostname != "{{ rabbitmq_master }}" + +- name: rabbitmq_clustering | joining rabbitmq cluster + command: rabbitmqctl join_cluster 'rabbit@{{ rabbitmq_master }}' + register: cluster_joined + when: inventory_hostname != "{{ rabbitmq_master }}" + +- name: rabbitmq_clustering | starting rabbitmq app + command: rabbitmqctl start_app + when: inventory_hostname != "{{ rabbitmq_master }}" + +- name: rabbitmq_clustering | marking as clustered + file: + path: /etc/rabbitmq/clustered + state: touch + when: cluster_master.changed or cluster_joined.changed -- cgit v1.2.3