Skip to content

redhat_subscription module broken with RHEL 9 #4741

@dkolepp

Description

@dkolepp

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:

- 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

$ ansible --version

Community.general Version

$ ansible-galaxy collection list community.general
Collection        Version
----------------- -------
community.general 5.0.0  

Configuration

$ ansible-config dump --only-changed

OS / Environment

RHEL 9

Steps to Reproduce

- 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", ""]}

Expected Results

I expected this to unsubscribe the host.

Actual Results

  "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

  • I agree to follow the Ansible Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bughas_prmodulemodule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions