From c78592730601ff449f984dfc3725245cbf972ce2 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Wed, 4 Sep 2024 09:39:28 +0100 Subject: [PATCH] Improve handling of rabbitmq_install_method changing Instead of using a conditional block, use the "state" parameter of the yum_repository module to ensure that the repo config is correctly added/removed if rabbitmq_install_method is changed after initial deployment. Change-Id: Ief07a74cd0019fefd58e27fb8dc4299b99299f99 --- tasks/install_yum.yml | 3 +-- vars/redhat.yml | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tasks/install_yum.yml b/tasks/install_yum.yml index 60e299b4..bea98746 100644 --- a/tasks/install_yum.yml +++ b/tasks/install_yum.yml @@ -28,11 +28,10 @@ baseurl: "{{ item.baseurl }}" gpgcheck: "{{ item.gpgcheck | default('no') }}" gpgkey: "{{ item.gpgkey | default(omit) }}" + state: "{{ item.state | default(omit) }}" with_items: - "{{ rabbitmq_erlang_repo }}" - "{{ rabbitmq_repo }}" - when: - - rabbitmq_install_method == 'external_repo' tags: - rabbitmq-repos diff --git a/vars/redhat.yml b/vars/redhat.yml index 584cb1ce..66546e2c 100644 --- a/vars/redhat.yml +++ b/vars/redhat.yml @@ -29,6 +29,7 @@ _rabbitmq_repo: description: "RabbitMQ Server Rolling Repository" baseurl: "{{ rabbitmq_repo_url }}" filename: RabbitMQ + state: "{{ (rabbitmq_install_method == 'external_repo') | ternary('present', 'absent') }}" gpgcheck: yes gpgkey: - https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc @@ -41,6 +42,7 @@ _rabbitmq_erlang_repo: description: "RabbitMQ Erlang Packages" baseurl: "{{ rabbitmq_erlang_repo_url }}" filename: els-erlang + state: "{{ (rabbitmq_erlang_install_method == 'external_repo') | ternary('present', 'absent') }}" gpgcheck: yes gpgkey: - https://dl.cloudsmith.io/public/rabbitmq/rabbitmq-erlang/gpg.E495BB49CC4BBE5B.key