From add595e12175b00dbf4746ada298fab1ccf80076 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 19:47:22 +0100 Subject: [PATCH] [PR #9578/bcc92e8a backport][stable-10] redhat_subscription: stop manual unsubscribing on unregistration (#9590) redhat_subscription: stop manual unsubscribing on unregistration (#9578) Unregistering a system also drops all the resources for it automatically, so there is no need to manually unsubscribing (which actually means removing all the subscriptions). In addition to that, newer versions of subscription-manager drop all the support for entitlements, so the "remove" subcommand (used by unsubscribe()) does not exist anymore, and thus the unregistration fails with those versions. This fixes the registration on EL 10 systems, and Fedora 41 and greater. (cherry picked from commit bcc92e8aac4397117e14386ff462c7399bd7db6e) Co-authored-by: Pino Toscano --- .../9578-redhat_subscription-no-remove-on-unregister.yml | 7 +++++++ plugins/modules/redhat_subscription.py | 1 - tests/unit/plugins/modules/test_redhat_subscription.py | 5 ----- 3 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 changelogs/fragments/9578-redhat_subscription-no-remove-on-unregister.yml diff --git a/changelogs/fragments/9578-redhat_subscription-no-remove-on-unregister.yml b/changelogs/fragments/9578-redhat_subscription-no-remove-on-unregister.yml new file mode 100644 index 0000000000..1403b2faa1 --- /dev/null +++ b/changelogs/fragments/9578-redhat_subscription-no-remove-on-unregister.yml @@ -0,0 +1,7 @@ +bugfixes: + - | + redhat_subscription - do not try to unsubscribe (i.e. remove subscriptions) + when unregistering a system: newer versions of subscription-manager, as + available in EL 10 and Fedora 41+, do not support entitlements anymore, and + thus unsubscribing will fail + (https://github.com/ansible-collections/community.general/pull/9578). diff --git a/plugins/modules/redhat_subscription.py b/plugins/modules/redhat_subscription.py index 0ed06bc92e..0b740645db 100644 --- a/plugins/modules/redhat_subscription.py +++ b/plugins/modules/redhat_subscription.py @@ -1119,7 +1119,6 @@ def main(): module.exit_json(changed=False, msg="System already unregistered.") else: try: - rhsm.unsubscribe() rhsm.unregister() except Exception as e: module.fail_json(msg="Failed to unregister: %s" % to_native(e)) diff --git a/tests/unit/plugins/modules/test_redhat_subscription.py b/tests/unit/plugins/modules/test_redhat_subscription.py index 7be3740d26..bbdbbdab7d 100644 --- a/tests/unit/plugins/modules/test_redhat_subscription.py +++ b/tests/unit/plugins/modules/test_redhat_subscription.py @@ -199,11 +199,6 @@ TEST_CASES = [ {'check_rc': False}, (0, 'system identity: b26df632-25ed-4452-8f89-0308bfd167cb', '') ), - ( - ['/testbin/subscription-manager', 'remove', '--all'], - {'check_rc': True}, - (0, '', '') - ), ( ['/testbin/subscription-manager', 'unregister'], {'check_rc': True},