Repository: ansible-collections/community.general

Issue:
redhat_subscription module broken with RHEL 9
### Summary

When I try to ensure that a system does not have a subscription active, I get a failed task for a RHEL 9 system.

Example:
```yaml
- name: Ensure system subscription is absent
  redhat_subscription:
    state: absent
    activationkey: "{{ sat_activationkey }}"
    org_id: "{{ sat_organization }}"
```
fails for a RHEL9 host.



### Issue Type

Bug Report

### Component Name

redhat_subscription

### Ansible Version

```console (paste below)
$ ansible --version

```


### Community.general Version

```console (paste below)
$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 5.0.0  

```


### Configuration

```console (paste below)
$ ansible-config dump --only-changed

```


### OS / Environment

RHEL 9

### Steps to Reproduce

<!--- Paste example playbooks or commands between quotes below -->
```yaml
- name: Ensure system subscription is absent
  redhat_subscription:
    state: absent
    activationkey: "{{ sat_activationkey }}"
    org_id: "{{ sat_organization }}"
```
for a RHEL9 host, the task fails:
```
fatal: [servera]: FAILED! => {"changed": false, "cmd": "/sbin/subscription-manager unsubscribe --all", "msg": "", "rc": 1, "stderr": "", "stderr_lines": [], "stdout": "Usage: subscription-manager MODULE-NAME [MODULE-OPTIONS] [--help]\n\r\nPrimary Modules: \n\n  attach         Attach a specified subscription to the registered system, when system does not use Simple Content Access mode\n  list           List subscription and product information for this system\n  refresh        Pull the latest subscription data from the server\n  register       Register this system to the Customer Portal or another subscription management service\n  release        Configure which operating system release to use\n  remove         Remove all or specific subscriptions from this system\n  status         Show status information for this system's subscriptions and products\n  unregister     Unregister this system from the Customer Portal or another subscription management service\n\nOther Modules:   \n\n  addons         Deprecated, see 'syspurpose'\n  auto-attach    Set if subscriptions are attached on a schedule (default of daily)\n  clean          Remove all local system and subscription data without affecting the server\n  config         List, set, or remove the configuration parameters in use by this system\n  environments   Display the environments available for a user\n  facts          View or update the detected system information\n  identity       Display the identity certificate for this system or request a new one\n  import         Import certificates which were provided outside of the tool\n  orgs           Display the organizations against which a user can register a system\n  plugins        View and configure with 'subscription-manager plugins'\n  redeem         Attempt to redeem a subscription for a preconfigured system\n  repo-override  Manage custom content repository settings\n  repos          List the repositories which this system is entitled to use\n  role           Deprecated, see 'syspurpose'\n  service-level  Deprecated, see 'syspurpose'\n  syspurpose     Convenient module for managing all system purpose settings\n  usage          Deprecated, see 'syspurpose'\n  version        Print version information\n\n", "stdout_lines": ["Usage: subscription-manager MODULE-NAME [MODULE-OPTIONS] [--help]", "", "Primary Modules: ", "", "  attach         Attach a specified subscription to the registered system, when system does not use Simple Content Access mode", "  list           List subscription and product information for this system", "  refresh        Pull the latest subscription data from the server", "  register       Register this system to the Customer Portal or another subscription management service", "  release        Configure which operating system release to use", "  remove         Remove all or specific subscriptions from this system", "  status         Show status information for this system's subscriptions and products", "  unregister     Unregister this system from the Customer Portal or another subscription management service", "", "Other Modules:   ", "", "  addons         Deprecated, see 'syspurpose'", "  auto-attach    Set if subscriptions are attached on a schedule (default of daily)", "  clean          Remove all local system and subscription data without affecting the server", "  config         List, set, or remove the configuration parameters in use by this system", "  environments   Display the environments available for a user", "  facts          View or update the detected system information", "  identity       Display the identity certificate for this system or request a new one", "  import         Import certificates which were provided outside of the tool", "  orgs           Display the organizations against which a user can register a system", "  plugins        View and configure with 'subscription-manager plugins'", "  redeem         Attempt to redeem a subscription for a preconfigured system", "  repo-override  Manage custom content repository settings", "  repos          List the repositories which this system is entitled to use", "  role           Deprecated, see 'syspurpose'", "  service-level  Deprecated, see 'syspurpose'", "  syspurpose     Convenient module for managing all system purpose settings", "  usage          Deprecated, see 'syspurpose'", "  version        Print version information", ""]}
```

```yaml (paste below)

```


### Expected Results

I expected this to unsubscribe the host.

### Actual Results

```console (paste below)
  "stdout_lines": [
    "Usage: subscription-manager MODULE-NAME [MODULE-OPTIONS] [--help]",
    "",
    "Primary Modules: ",
    "",
    "  attach         Attach a specified subscription to the registered system, when system does not use Simple Content Access mode",
    "  list           List subscription and product information for this system",
    "  refresh        Pull the latest subscription data from the server",
    "  register       Register this system to the Customer Portal or another subscription management service",
    "  release        Configure which operating system release to use",
    "  remove         Remove all or specific subscriptions from this system",
    "  status         Show status information for this system's subscriptions and products",
    "  unregister     Unregister this system from the Customer Portal or another subscription management service",
    "",
    "Other Modules:   ",
    "",
    "  addons         Deprecated, see 'syspurpose'",
    "  auto-attach    Set if subscriptions are attached on a schedule (default of daily)",
    "  clean          Remove all local system and subscription data without affecting the server",
    "  config         List, set, or remove the configuration parameters in use by this system",
    "  environments   Display the environments available for a user",
    "  facts          View or update the detected system information",
    "  identity       Display the identity certificate for this system or request a new one",
    "  import         Import certificates which were provided outside of the tool",
    "  orgs           Display the organizations against which a user can register a system",
    "  plugins        View and configure with 'subscription-manager plugins'",
    "  redeem         Attempt to redeem a subscription for a preconfigured system",
    "  repo-override  Manage custom content repository settings",
    "  repos          List the repositories which this system is entitled to use",
    "  role           Deprecated, see 'syspurpose'",
    "  service-level  Deprecated, see 'syspurpose'",
    "  syspurpose     Convenient module for managing all system purpose settings",
    "  usage          Deprecated, see 'syspurpose'",
    "  version        Print version information",
    ""
  ]
}
```
This appears to happen because in RHEL 9, `subscription-manager unsubscribe` is not a valid command sequence.  There is not `unsubscribe` sub-command (but there is, in RHEL 8).

### Code of Conduct

- [X] I agree to follow the Ansible Code of Conduct


Discussion:
Files identified in the description:
None

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
Files identified in the description:
* [`plugins/modules/packaging/os/redhat_subscription.py`](https://github.com/ansible-collections/community.general/blob/main/plugins/modules/packaging/os/redhat_subscription.py)

If these files are incorrect, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @alikins @barnabycourt @kahowell
[click here for bot help](https://github.com/ansible/ansibullbot/blob/devel/ISSUE_HELP.md)
<!--- boilerplate: notify --->
`subscription-manager unsubscribe` was marked as deprecated on RHEL 7 already. I assume the replacement should be

```bash
subscription-manager remove --all
subscription-manager unregister
```

Resolving patch:
diff --git a/plugins/modules/packaging/os/redhat_subscription.py b/plugins/modules/packaging/os/redhat_subscription.py
--- a/plugins/modules/packaging/os/redhat_subscription.py
+++ b/plugins/modules/packaging/os/redhat_subscription.py
@@ -468,7 +468,7 @@ def unsubscribe(self, serials=None):
             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
 


Test patch:
diff --git a/tests/unit/plugins/modules/packaging/os/test_redhat_subscription.py b/tests/unit/plugins/modules/packaging/os/test_redhat_subscription.py
--- 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 @@ def test_without_required_parameters(capfd, patch_redhat_subscription):
                     (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 @@ def test_without_required_parameters(capfd, patch_redhat_subscription):
                 (
                     [
                         '/testbin/subscription-manager',
-                        'unsubscribe',
+                        'remove',
                         '--serial=7807912223970164816',
                     ],
                     {'check_rc': True},