oasis_roles.rhsm
This Role Is No Longer Supported: Please Use the Version in the oasis_roles.system Ansible Collection
RHSM
This role helps you register or unregister a system using subscription-manager
, and allows you to enable or disable repositories linked to your subscription.
Requirements
- Ansible version 2.8 or higher
- Red Hat Enterprise Linux 7 or an equivalent system
- Valid Red Hat subscriptions
Role Variables
The following variables can be used:
Subscription Management
These variables are used with the redhat_subscription module:
rhsm_username
: Your Red Hat or Satellite usernamerhsm_password
: Your Red Hat or Satellite passwordrhsm_org_id
: Your organization ID in RHSMrhsm_activationkey
: Your activation key for RHSMrhsm_server_hostname
: Hostname for a different RHSM providerrhsm_server_insecure
: Disable certificate checks (boolean, default is false)rhsm_baseurl
: Alternate base URL for repositories if not using Red Hat CDNrhsm_server_proxy_hostname
: HTTP proxy hostnamerhsm_server_proxy_port
: HTTP proxy portrhsm_server_proxy_user
: HTTP proxy usernamerhsm_server_proxy_password
: HTTP proxy passwordrhsm_auto_attach
: Automatically attach to available subscriptions if registration succeeds (boolean, default is false)rhsm_environment
: Register with a specific environment (for Red Hat Satellite 6 or Katello)rhsm_pool
: Name of the pool to consume (userhsm_pool_ids
when possible; they're faster)rhsm_pool_ids
: List of pool IDs to consumerhsm_consumer_type
: Type of unit to register (default is "system")rhsm_consumer_name
: Name of the system (default is the hostname)rhsm_consumer_id
: Existing consumer ID for resuming registrationrhsm_force_register
: Force registration even if already registered (boolean, default is false)rhsm_syspurpose
: Attributes for creatingsyspurpose.json
on RHEL 8 systems (requires ansible>=2.9)rhsm_unregister
: Unregister the system if true (boolean, default is false)
Repository Management
Note: Using repository management variables may cause errors if the system is not registered. Subscription tasks run before repository tasks to ensure the system is correctly registered.
rhsm_release
: Specify the operating system release version to use (quote versions that look like numbers, e.g.,"7.4"
)rhsm_release_unset
: Unset the operating system release version (boolean, default is false)rhsm_repositories
: Control which repositories to enable/disable
If both rhsm_release
and rhsm_release_unset
are set, rhsm_release_unset
will take precedence.
To enable/disable specific repositories:
rhsm_repositories:
enabled:
- enabled-repository
disabled:
- disabled-repository
To enable only certain repositories while disabling all others:
rhsm_repositories:
disabled:
- '*'
enabled:
- enabled-repository-1
- enabled-repository-2
You can also use wildcards for repository names:
rhsm_repositories:
disabled:
- '*'
enabled:
- 'enabled-repository*'
To specify a specific version of RHEL repositories:
rhsm_release: "7.1"
To always use the latest minor version of repositories:
rhsm_release_unset: true
Dependencies
Requires a system that can install and use subscription-manager
, like Red Hat Enterprise Linux.
This role needs elevated privileges (sudo) to work.
Example Playbooks
This playbook registers a system with a username and password, auto-attaches it, enables three RHEL 7 repositories, and sets the repository release version to "7Server".
- hosts: rhsm-servers
roles:
- role: rhsm
vars:
rhsm_username: your_username
rhsm_password: your_password
rhsm_auto_attach: true
rhsm_repositories:
only:
- rhel-7-server-rpms
- rhel-7-server-optional-rpms
- rhel-7-server-extras-rpms
rhsm_release: 7Server
This example registers a system to Red Hat Satellite 6 using an organization ID and activation key, connecting to a specific pool by ID.
- hosts: rhsm-servers
roles:
- role: rhsm
vars:
rhsm_org_id: your_organization_id
rhsm_activationkey: activation_key
rhsm_pool_ids:
- poolid
rhsm_server_hostname: your.satellite6.hostname
Make sure to install CA certificates for Satellite 6 or Katello host first to use HTTPS with RHSM.
Changes
rhsm_repositories.only
deprecated
The only
syntax for repositories has been deprecated. Instead, you can now use:
rhsm_repositories:
disabled:
- '*'
enabled:
- enabled-repository-1
- enabled-repository-2
This change ensures a clearer and more consistent way to manage repositories.
Requires Ansible >= 2.8
This role uses new features from the rhsm_repository
Ansible module. If you're using an older version, you can get version 2.0.0 of this role:
# example requirements.yaml to install version 2.0.0
- name: oasis_roles.rhsm
version: 2.0.0
License
Author Information
Sean Myers semyers@redhat.com
ansible-galaxy install oasis_roles.rhsm