diff --git a/changelogs/fragments/4809-redhat_subscription-unsubscribe.yaml b/changelogs/fragments/4809-redhat_subscription-unsubscribe.yaml new file mode 100644 index 0000000000..39a364d007 --- /dev/null +++ b/changelogs/fragments/4809-redhat_subscription-unsubscribe.yaml @@ -0,0 +1,2 @@ +bugfixes: + - redhat_subscription - fix unsubscribing on RHEL 9 (https://github.com/ansible-collections/community.general/issues/4741). diff --git a/plugins/modules/packaging/os/redhat_subscription.py b/plugins/modules/packaging/os/redhat_subscription.py index 7bb540b3f1..7309ba7d66 100644 --- a/plugins/modules/packaging/os/redhat_subscription.py +++ b/plugins/modules/packaging/os/redhat_subscription.py @@ -468,7 +468,7 @@ class Rhsm(RegistrationBase): items = ["--all"] if items: - args = [SUBMAN_CMD, 'unsubscribe'] + items + args = [SUBMAN_CMD, 'remove'] + items rc, stderr, stdout = self.module.run_command(args, check_rc=True) return serials diff --git a/tests/unit/plugins/modules/packaging/os/test_redhat_subscription.py b/tests/unit/plugins/modules/packaging/os/test_redhat_subscription.py index 7f430ee72c..8eb7ead674 100644 --- a/tests/unit/plugins/modules/packaging/os/test_redhat_subscription.py +++ b/tests/unit/plugins/modules/packaging/os/test_redhat_subscription.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- # Author: Jiri Hnidek (jhnidek@redhat.com) # # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) @@ -118,7 +119,7 @@ TEST_CASES = [ (0, 'system identity: b26df632-25ed-4452-8f89-0308bfd167cb', '') ), ( - ['/testbin/subscription-manager', 'unsubscribe', '--all'], + ['/testbin/subscription-manager', 'remove', '--all'], {'check_rc': True}, (0, '', '') ), @@ -755,7 +756,7 @@ Entitlement Type: Physical ( [ '/testbin/subscription-manager', - 'unsubscribe', + 'remove', '--serial=7807912223970164816', ], {'check_rc': True},