nycrecords.rhsm
Ansible Role: RHSM
This role helps register or unregister a system using subscription-manager, and can also turn on or off available subscription repositories.
Requirements
- Ansible version 2.4 or higher
- Red Hat Enterprise Linux 7 or similar
- Valid Red Hat subscriptions
Role Variables
The following variables are available:
Subscription Management
These variables relate to the redhat_subscription module.
- rhsm_username- username for access.redhat.com or Satellite
- rhsm_password- password for access.redhat.com or Satellite
- rhsm_org_id- organization ID for RHSM Provider
- rhsm_activationkey- activation key for RHSM Provider
- rhsm_server_hostname- hostname for alternate RHSM provider
- rhsm_server_insecure- if true, skips certificate verification (default false)
- rhsm_baseurl- alternate base URL for package repositories
- rhsm_server_proxy_hostname- HTTP proxy hostname
- rhsm_server_proxy_port- HTTP proxy port
- rhsm_server_proxy_user- HTTP proxy username
- rhsm_server_proxy_password- HTTP proxy password
- rhsm_auto_attach- automatically use available subscriptions if registration succeeds (default false)
- rhsm_environment- specify the environment to register with (for Red Hat Satellite 6 or Katello)
- rhsm_pool- name of the pool to use (you can use regex). Prefer using- rhsm_pool_ids.
- rhsm_pool_ids- a list of pool IDs or dicts for pool IDs and how many licenses to use. Cannot use with- rhsm_pool.
- rhsm_consumer_type- type of unit to register (defaults to "system")
- rhsm_consumer_name- name of the system (defaults to hostname)
- rhsm_consumer_id- existing consumer ID for resuming a registration
- rhsm_force_register- if true, registers the system even if it’s already registered (default false)
- rhsm_unregister- if true, unregisters the system (default false; registration won't be tried).
Repository Management
Note: If the system is not registered, using repository variables might cause errors. Registration happens before processing repository variables.
- rhsm_release- set the OS release version; use quotes for versions that look like decimals (e.g., set to "7.4").
- rhsm_release_unset- clear the OS release version (default false).
- rhsm_repositories- specifies which repositories to enable or disable.
To enable/disable specific repositories:
rhsm_repositories:
  enabled:
    - enabled-repository
  disabled:
    - disabled-repository
The disabled list is checked before enabled.
To enable specific repositories and disable all others:
rhsm_repositories:
  only:
    - enabled-repository-1
    - enabled-repository-2
Using only is a friendlier version of the following:
rhsm_repositories:
  disabled:
    - "*"
  enabled:
    - enabled-repository-1
    - enabled-repository-2
You can use wildcard characters in repository names. Using only excludes using enabled or disabled together.
To specify a minor version of the RHEL repositories:
rhsm_release: "7.1"
To always use the latest minor version:
rhsm_release_unset: true
Role Output
DEPRECATION WARNING Role outputs are deprecated and will be removed in a future version.
oasis_role_rhsm
The oasis_role_rhsm fact will indicate:
- subscribed- whether the system is registered (true/false).
- subscribed_pool_ids- list of pool IDs currently attached to the system (empty if no pools are attached or not registered).
Dependencies
Requires a system that supports subscription-manager, like Red Hat Enterprise Linux.
This role needs sudo privileges to work.
Example Playbooks
This playbook registers a system with a username and password, attaches it to available subscriptions, and enables three RHEL 7 repositories, setting 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 playbook registers a system with Red Hat Satellite 6 using an organization ID and activation key, and attaches 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 before using HTTPS.
License
Author Information
Joel Castillo (@joelbcastillo) for the NYC Department of Records Dev Team (@nycrecords)
Forked from Sean Myers semyers@redhat.com (oasis-roles/rhsm)
Role to setup subscription management on RedHat Enterprise Linux. Forked from https://github.com/oasis-roles/rhsm
ansible-galaxy install nycrecords.rhsm