Skip to content

Commit

Permalink
Resolve conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-schattenberg-itential committed Sep 23, 2024
1 parent d650e9e commit 3e59025
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 204 deletions.
8 changes: 4 additions & 4 deletions roles/rabbitmq/tasks/configure-clustering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- name: Write all RabbitMQ nodes to the hosts file
ansible.builtin.lineinfile:
path: "/etc/hosts"
line: "{{ hostvars[item].ansible_default_ipv4.address }} rabbit{{ my_idx + 1 }} {{ hostvars[item].ansible_hostname }}"
line: "{{ hostvars[item].ansible_default_ipv4.address }} {{ item }} {{ hostvars[item].inventory_hostname_short }} rabbit{{ my_idx + 1 }}"
loop: "{{ lookup('inventory_hostnames', 'rabbitmq', wantlist=True) }}"
loop_control:
index_var: my_idx
Expand All @@ -13,7 +13,7 @@
- name: Write all RabbitMQ nodes to the hosts file for secondary DR
ansible.builtin.lineinfile:
path: "/etc/hosts"
line: "{{ hostvars[item].ansible_default_ipv4.address }} rabbit{{ my_idx + 1 }} {{ hostvars[item].ansible_hostname }}"
line: "{{ hostvars[item].ansible_default_ipv4.address }} {{ item }} {{ hostvars[item].inventory_hostname_short }} rabbit{{ my_idx + 1 }}"
loop: "{{ lookup('inventory_hostnames', 'rabbitmq_secondary', wantlist=True) }}"
loop_control:
index_var: my_idx
Expand All @@ -25,7 +25,7 @@
ansible.builtin.lineinfile:
path: "{{ rabbitmq_config }}"
insertafter: "cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config"
line: "cluster_formation.classic_config.nodes.{{ my_idx + 1 }} = rabbit@{{ hostvars[item].ansible_hostname }}"
line: "cluster_formation.classic_config.nodes.{{ my_idx + 1 }} = rabbit@{{ hostvars[item].inventory_hostname_short }}"
loop: "{{ lookup('inventory_hostnames', 'rabbitmq', wantlist=True) }}"
loop_control:
index_var: my_idx
Expand All @@ -35,7 +35,7 @@
ansible.builtin.lineinfile:
path: "{{ rabbitmq_config }}"
insertafter: "cluster_formation.peer_discovery_backend = rabbit_peer_discovery_classic_config"
line: "cluster_formation.classic_config.nodes.{{ my_idx + 1 }} = rabbit@{{ hostvars[item].ansible_hostname }}"
line: "cluster_formation.classic_config.nodes.{{ my_idx + 1 }} = rabbit@{{ hostvars[item].inventory_hostname_short }}"
loop: "{{ lookup('inventory_hostnames', 'rabbitmq_secondary', wantlist=True) }}"
loop_control:
index_var: my_idx
Expand Down
24 changes: 12 additions & 12 deletions roles/rabbitmq/tasks/enable-clustering.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
changed_when: output.rc != 0
when:
- inventory_hostname in groups['rabbitmq']
- hostvars[groups['rabbitmq'][0]].ansible_hostname != ansible_hostname
- groups.rabbitmq.index(inventory_hostname) != 0

- name: Stop RabbitMQ for secondary
ansible.builtin.command:
Expand All @@ -21,7 +21,7 @@
when:
- groups['rabbitmq_secondary'] is defined
- inventory_hostname in groups['rabbitmq_secondary']
- hostvars[groups['rabbitmq_secondary'][0]].ansible_hostname != ansible_hostname
- groups.rabbitmq_secondary.index(inventory_hostname) != 0

- name: Reset node
ansible.builtin.command:
Expand All @@ -30,7 +30,7 @@
changed_when: output.rc != 0
when:
- inventory_hostname in groups['rabbitmq']
- hostvars[groups['rabbitmq'][0]].ansible_hostname != ansible_hostname
- groups.rabbitmq.index(inventory_hostname) != 0

- name: Reset node for secondary
ansible.builtin.command:
Expand All @@ -40,26 +40,26 @@
when:
- groups['rabbitmq_secondary'] is defined
- inventory_hostname in groups['rabbitmq_secondary']
- hostvars[groups['rabbitmq_secondary'][0]].ansible_hostname != ansible_hostname
- groups.rabbitmq_secondary.index(inventory_hostname) != 0

- name: Join cluster
ansible.builtin.command:
cmd: "rabbitmqctl join_cluster rabbit@{{ hostvars[groups['rabbitmq'][0]].ansible_hostname }}"
cmd: "rabbitmqctl join_cluster rabbit@{{ hostvars[groups['rabbitmq'][0]].inventory_hostname_short }}"
register: output
changed_when: output.rc != 0
when:
- inventory_hostname in groups['rabbitmq']
- hostvars[groups['rabbitmq'][0]].ansible_hostname != ansible_hostname
- inventory_hostname in groups.rabbitmq
- groups.rabbitmq.index(inventory_hostname) != 0

- name: Join cluster for secondary DR
ansible.builtin.command:
cmd: "rabbitmqctl join_cluster rabbit@{{ hostvars[groups['rabbitmq_secondary'][0]].ansible_hostname }}"
cmd: "rabbitmqctl join_cluster rabbit@{{ hostvars[groups['rabbitmq_secondary'][0]].inventory_hostname_short }}"
register: output
changed_when: output.rc != 0
when:
- groups['rabbitmq_secondary'] is defined
- inventory_hostname in groups['rabbitmq_secondary']
- hostvars[groups['rabbitmq_secondary'][0]].ansible_hostname != ansible_hostname
- inventory_hostname in groups.rabbitmq_secondary
- groups.rabbitmq_secondary.index(inventory_hostname) != 0

- name: Restart RabbitMQ server
ansible.builtin.systemd:
Expand All @@ -68,7 +68,7 @@
state: restarted
when:
- inventory_hostname in groups['rabbitmq']
- hostvars[groups['rabbitmq'][0]].ansible_hostname != ansible_hostname
- groups.rabbitmq.index(inventory_hostname) != 0

- name: Restart RabbitMQ server for secondary
ansible.builtin.systemd:
Expand All @@ -78,7 +78,7 @@
when:
- groups['rabbitmq_secondary'] is defined
- inventory_hostname in groups['rabbitmq_secondary']
- hostvars[groups['rabbitmq_secondary'][0]].ansible_hostname != ansible_hostname
- groups.rabbitmq_secondary.index(inventory_hostname) != 0

# From the cmd line run this to set the proper HA policy on the iap vhost
# rabbitmqctl set_policy ha-all -p iap ".*" '{"ha-mode":"all", "ha-promote-on-shutdown": "when-synced", "ha-sync-mode": "automatic"}'
Expand Down
188 changes: 0 additions & 188 deletions roles/rabbitmq_cluster/tasks/main.yml

This file was deleted.

0 comments on commit 3e59025

Please sign in to comment.