community.general.redhat_subscription module – Manage registration and subscriptions to RHSM using subscription-manager
Note
This module is part of the community.general collection (version 10.0.1).
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.redhat_subscription
.
Synopsis
Manage registration and subscription to the Red Hat Subscription Management entitlement platform using the
subscription-manager
command, registering using D-Bus if possible.
Requirements
The below requirements are needed on the host that executes this module.
subscription-manager
Optionally the
dbus
Python library; this is usually included in the OS as it is used bysubscription-manager
.
Parameters
Parameter |
Comments |
---|---|
supply an activation key for use with registration |
|
Upon successful registration, auto-consume available subscriptions Please note that the alias Choices:
|
|
References an existing consumer ID to resume using a previous registration for this system. If the system’s identity certificate is lost or corrupted, this option allows it to resume using its previous identity and subscriptions. The default is to not specify a consumer ID so a new ID is created. |
|
Name of the system to register, defaults to the hostname |
|
The type of unit to register, defaults to system |
|
Register with a specific environment in the destination org. Used with Red Hat Satellite or Katello |
|
Register the system even if it is already registered Choices:
|
|
Organization ID to use in conjunction with activationkey |
|
access.redhat.com or Red Hat Satellite or Katello password |
|
Specify subscription pool IDs to consume.
A pool ID may be specified as a Default: |
|
Set a release version |
|
Specify CDN baseurl |
|
Specify an alternative location for a CA certificate for CDN |
|
Specify an alternative Red Hat Subscription Management or Red Hat Satellite or Katello server. |
|
Enable or disable https server certificate verification when connecting to |
|
Specify the port when registering to the Red Hat Subscription Management or Red Hat Satellite or Katello server. |
|
Specify the prefix when registering to the Red Hat Subscription Management or Red Hat Satellite or Katello server. |
|
Specify an HTTP proxy hostname. |
|
Specify a password for HTTP proxy with basic authentication |
|
Specify an HTTP proxy port. |
|
Specify an HTTP proxy scheme, for example |
|
Specify a user for HTTP proxy with basic authentication |
|
whether to register and subscribe ( Choices:
|
|
Set syspurpose attributes in file |
|
Syspurpose attribute addons |
|
Syspurpose attribute role |
|
Syspurpose attribute service_level_agreement |
|
When this option is Choices:
|
|
Syspurpose attribute usage |
|
sso.redhat.com API access token. |
|
access.redhat.com or Red Hat Satellite or Katello username |
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: none |
Can run in |
|
Support: none |
Will return details on what has changed (or possibly needs changing in |
Notes
Note
The module tries to use the D-Bus
rhsm
service (part ofsubscription-manager
) to register, starting from community.general 6.5.0: this is done so credentials (username, password, activation keys) can be passed torhsm
in a secure way.subscription-manager
itself gets credentials only as arguments of command line parameters, which is not secure, as they can be easily stolen by checking the process listing on the system. Due to limitations of the D-Bus interface ofrhsm
, the module will not use D-Bus for registration when trying either to register usingtoken
, or when specifyingenvironment
, or when the system is old (typically RHEL 7 older than 7.4, RHEL 6, and older).In order to register a system, subscription-manager requires either a username and password, or an activationkey and an Organization ID.
Since 2.5 values for
server_hostname
,server_insecure
,rhsm_baseurl
,server_proxy_hostname
,server_proxy_port
,server_proxy_user
andserver_proxy_password
are no longer taken from the/etc/rhsm/rhsm.conf
config file and default tonull
.It is possible to interact with
subscription-manager
only as root, so root permissions are required to successfully run this module.Since community.general 6.5.0, credentials (that is,
username
andpassword
,activationkey
, ortoken
) are needed only in case the the system is not registered, orforce_register
is specified; this makes it possible to use the module to tweak an already registered system, for example attaching pools to it (usingpool_ids
), and modifying thesyspurpose
attributes (usingsyspurpose
).
Examples
- name: Register as user (joe_user) with password (somepass) and auto-subscribe to available content.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
auto_attach: true
- name: Same as above but subscribe to a specific pool by ID.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
pool_ids: 0123456789abcdef0123456789abcdef
- name: Register and subscribe to multiple pools.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
pool_ids:
- 0123456789abcdef0123456789abcdef
- 1123456789abcdef0123456789abcdef
- name: Same as above but consume multiple entitlements.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
pool_ids:
- 0123456789abcdef0123456789abcdef: 2
- 1123456789abcdef0123456789abcdef: 4
- name: Register and pull existing system data.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
consumer_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- name: Register as user credentials into given environment (against Red Hat Satellite or Katello), and auto-subscribe.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
environment: Library
auto_attach: true
- name: Register as user (joe_user) with password (somepass) and a specific release
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
release: 7.4
- name: Register as user (joe_user) with password (somepass), set syspurpose attributes and synchronize them with server
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
auto_attach: true
syspurpose:
usage: "Production"
role: "Red Hat Enterprise Server"
service_level_agreement: "Premium"
addons:
- addon1
- addon2
sync: true
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
List of pool IDs to which system is now subscribed Returned: success Sample: |