From f546a6fd96841d2cb48ac7485ecf3f27eab6070f Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Mon, 17 Jan 2022 14:47:19 +0100 Subject: [PATCH] copr-builders: automatically unsubscribe when subscription fails Seems the subscription manager Ansible module fails to unregister the machine when the pool attachement fails. This terminates our playbook, and the whole machine - but RHSM keeps tracking the system. --- .../files/provision/provision_builder_tasks.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/roles/copr/backend/files/provision/provision_builder_tasks.yml b/roles/copr/backend/files/provision/provision_builder_tasks.yml index f6bf6c4496..c23e7c09ea 100644 --- a/roles/copr/backend/files/provision/provision_builder_tasks.yml +++ b/roles/copr/backend/files/provision/provision_builder_tasks.yml @@ -101,6 +101,16 @@ - copr_red_hat_subscription_password is defined tags: - red_hat_subscription + ignore_errors: true + register: subscription + +- name: Cleanup subscription before failure + community.general.redhat_subscription: + state: absent + when: subscription.failed + +- fail: msg="Could not subscribe" + when: subscription.failed - name: install copr-builder and other latest packages dnf: state=latest pkg={{ packages }}