community.general.rhsm_repository module – Manage RHSM repositories using the subscription-manager command

Note

This module is part of the community.general collection (version 7.5.2).

You might already have this collection installed if you are using the ansible package. It is not included in ansible-core. To check whether it is installed, run ansible-galaxy collection list.

To install it, use: ansible-galaxy collection install community.general. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: community.general.rhsm_repository.

Synopsis

  • Manage (Enable/Disable) RHSM repositories to the Red Hat Subscription Management entitlement platform using the subscription-manager command.

Aliases: packaging.os.rhsm_repository

Requirements

The below requirements are needed on the host that executes this module.

  • subscription-manager

Parameters

Parameter

Comments

name

list / elements=string / required

The ID of repositories to enable.

To operate on several repositories this can accept a comma separated list or a YAML list.

purge

boolean

Disable all currently enabled repositories that are not not specified in name. Only set this to true if passing in a list of repositories to the name field. Using this with loop will most likely not have the desired result.

Choices:

  • false ← (default)

  • true

state

string

If state is equal to present or disabled, indicates the desired repository state.

Please note that present and absent are deprecated, and will be

removed in community.general 10.0.0; please use enabled and disabled instead.

Choices:

  • "present"

  • "enabled" ← (default)

  • "absent"

  • "disabled"

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying target.

diff_mode

Support: full

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode.

Notes

Note

  • In order to manage RHSM repositories the system must be already registered to RHSM manually or using the Ansible community.general.redhat_subscription module.

  • It is possible to interact with subscription-manager only as root, so root permissions are required to successfully run this module.

Examples

- name: Enable a RHSM repository
  community.general.rhsm_repository:
    name: rhel-7-server-rpms

- name: Disable all RHSM repositories
  community.general.rhsm_repository:
    name: '*'
    state: disabled

- name: Enable all repositories starting with rhel-6-server
  community.general.rhsm_repository:
    name: rhel-6-server*
    state: enabled

- name: Disable all repositories except rhel-7-server-rpms
  community.general.rhsm_repository:
    name: rhel-7-server-rpms
    purge: true

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

repositories

list / elements=string

The list of RHSM repositories with their states.

When this module is used to change the repository states, this list contains the updated states after the changes.

Returned: success

Authors

  • Giovanni Sciortino (@giovannisciortino)