[PR #9578/bcc92e8a backport][stable-9] redhat_subscription: stop manual unsubscribing on unregistration (#9589)

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 bcc92e8aac)

Co-authored-by: Pino Toscano <ptoscano@redhat.com>
pull/9629/head
patchback[bot] 2025-01-20 19:47:17 +01:00 committed by GitHub
parent 0361154ff3
commit 56a906e42b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 6 deletions

View File

@ -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).

View File

@ -1262,7 +1262,6 @@ def main():
module.exit_json(changed=False, msg="System already unregistered.") module.exit_json(changed=False, msg="System already unregistered.")
else: else:
try: try:
rhsm.unsubscribe()
rhsm.unregister() rhsm.unregister()
except Exception as e: except Exception as e:
module.fail_json(msg="Failed to unregister: %s" % to_native(e)) module.fail_json(msg="Failed to unregister: %s" % to_native(e))

View File

@ -199,11 +199,6 @@ TEST_CASES = [
{'check_rc': False}, {'check_rc': False},
(0, 'system identity: b26df632-25ed-4452-8f89-0308bfd167cb', '') (0, 'system identity: b26df632-25ed-4452-8f89-0308bfd167cb', '')
), ),
(
['/testbin/subscription-manager', 'remove', '--all'],
{'check_rc': True},
(0, '', '')
),
( (
['/testbin/subscription-manager', 'unregister'], ['/testbin/subscription-manager', 'unregister'],
{'check_rc': True}, {'check_rc': True},