aboutsummaryrefslogblamecommitdiffhomepage
path: root/tasks/rabbitmq_clustering.yml
blob: 9e48590e539e7b777a6320a095787fa9a1585b0a (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                                                   

                                             


                                                    

                                             




                                                      
              
 









                                                                                                 







                                                



                                             




                                                                  

                                             



                                                             

                                             


                                                                               

                                             




                                                        

                                             


                                                   

                                             


                                                    

                                             

                                                      
                                                                                                
                          

                                             


                                                   

                                             




                                                  



                                    
---
- name: rabbitmq_clustering | stopping rabbitmq app
  command: rabbitmqctl stop_app
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | resetting rabbitmq app
  command: rabbitmqctl reset
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | stopping rabbitmq-server
  service:
    name: rabbitmq-server
    state: stopped
  become: true

- name: rabbitmq_clustering | Capturing Erlang Cookie On Master
  command: "cat {{ rabbitmq_erlang_cookie_file }}"
  become: true
  register: "rabbitmq_erlang_cookie"
  when: inventory_hostname == rabbitmq_master

- name: rabbitmq_clustering | Setting Erlang Cookie Of Master on Non-Master
  set_fact:
    rabbitmq_erlang_cookie: "{{ hostvars[rabbitmq_master]['rabbitmq_erlang_cookie']['stdout'] }}"
  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
    # backing up in case the need to recover
    backup: yes
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | restarting rabbitmq-server on master
  service:
    name: rabbitmq-server
    state: restarted
  become: true
  when: inventory_hostname == rabbitmq_master

- name: rabbitmq_clustering | starting rabbitmq app on master
  command: rabbitmqctl start_app
  register: cluster_master
  become: true
  when: inventory_hostname == rabbitmq_master

- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes
  shell: pkill -u rabbitmq || true
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | restarting rabbitmq-server
  service:
    name: rabbitmq-server
    state: restarted
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | stopping rabbitmq app
  command: rabbitmqctl stop_app
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | resetting rabbitmq app
  command: rabbitmqctl reset
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | joining rabbitmq cluster
  command: rabbitmqctl join_cluster "rabbit@{{ hostvars[rabbitmq_master]['ansible_hostname'] }}"
  register: cluster_joined
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | starting rabbitmq app
  command: rabbitmqctl start_app
  become: true
  when: inventory_hostname != rabbitmq_master

- name: rabbitmq_clustering | marking as clustered
  file:
    path: /etc/rabbitmq/clustered
    state: touch
  become: true
  when: >
        cluster_master['changed'] or
        cluster_joined['changed']