diff --git a/ansible/roles/rabbitmq/tasks/deploy.yml b/ansible/roles/rabbitmq/tasks/deploy.yml index 6357f9a88c..e790621ad7 100644 --- a/ansible/roles/rabbitmq/tasks/deploy.yml +++ b/ansible/roles/rabbitmq/tasks/deploy.yml @@ -1,4 +1,8 @@ --- +- include_tasks: remove-ha-all-policy.yml + when: + - not om_enable_rabbitmq_high_availability | bool + - import_tasks: config.yml - import_tasks: check-containers.yml diff --git a/ansible/roles/rabbitmq/tasks/remove-ha-all-policy.yml b/ansible/roles/rabbitmq/tasks/remove-ha-all-policy.yml new file mode 100644 index 0000000000..2ba02289e6 --- /dev/null +++ b/ansible/roles/rabbitmq/tasks/remove-ha-all-policy.yml @@ -0,0 +1,29 @@ +--- +- block: + - name: Get container facts + become: true + kolla_container_facts: + container_engine: "{{ kolla_container_engine }}" + name: + - "{{ service.container_name }}" + register: container_facts + + - block: + - name: List RabbitMQ policies + become: true + command: "docker exec {{ service.container_name }} rabbitmqctl list_policies --silent" + register: rabbitmq_policies + changed_when: false + + - name: Remove ha-all policy from RabbitMQ + become: true + command: "docker exec {{ service.container_name }} rabbitmqctl clear_policy ha-all" + when: + - "'ha-all' in rabbitmq_policies.stdout" + when: container_facts[service.container_name] is defined + + delegate_to: "{{ groups[role_rabbitmq_groups] | first }}" + run_once: true + vars: + service_name: "rabbitmq" + service: "{{ rabbitmq_services[service_name] }}" diff --git a/ansible/roles/rabbitmq/tasks/upgrade.yml b/ansible/roles/rabbitmq/tasks/upgrade.yml index 82632c5ace..ed672c6aa2 100644 --- a/ansible/roles/rabbitmq/tasks/upgrade.yml +++ b/ansible/roles/rabbitmq/tasks/upgrade.yml @@ -1,4 +1,8 @@ --- +- include_tasks: remove-ha-all-policy.yml + when: + - not om_enable_rabbitmq_high_availability | bool + - import_tasks: config.yml - import_tasks: feature-flags.yml diff --git a/releasenotes/notes/rabbitmq-remove-ha-all-policy-when-not-required-81dcf64542c4805f.yaml b/releasenotes/notes/rabbitmq-remove-ha-all-policy-when-not-required-81dcf64542c4805f.yaml new file mode 100644 index 0000000000..fe8f6030ac --- /dev/null +++ b/releasenotes/notes/rabbitmq-remove-ha-all-policy-when-not-required-81dcf64542c4805f.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + When upgrading or deploying RabbitMQ, the policy `ha-all` is cleared if + `om_enable_rabbitmq_high_availability` is set to `false`.