Loading...

Watch: Register a system with Red Hat Subscription-Manager - Ansible module redhat_subscription

How to automate the registration of a machine RedHat Enterprise Linux 8 to subscription-manager using the access.redhat.com credential, assign a pool of entitlement, and install some packages.

How to register a system with Red Hat Subscription-Manager with Ansible?

I'm going to show you a live Playbook and some simple Ansible code.

I'm Luca Berton and welcome to today's episode of Ansible Pilot.

Ansible register a system with Red Hat Subscription-Manager

  • community.general.redhat_subscription
  • Manage registration and subscriptions to RHSM using the subscription-manager command

Today we're talking about the Ansible module redhat_subscription.

The full name is community.general.redhat_subscription, which means that is part of the collection community.general maintained by the Ansible community

Manage registration and subscriptions to RHSM using the subscription-manager command.

This module is specific for RedHat Enterprise Linux.

Parameters

  • state _string_ - present/absent
  • username _string_ - access.redhat.com or Satellite 6 username
  • password _string_ - access.redhat.com or Satellite 6 password
  • auto_attach _boolean_ - no/yes auto-consume available subscriptions
  • pool_id _list_ - subscription pool IDs to consume

Let me summarize the main parameters.

The state parameter allows you to specify if you want to add or remove a registration from the target machine.

The username and password allow you to specify the access.redhat.com website credential or Satellite 6 credential.

Once the machine is registered you need to define which subscription to consume.

The auto_attach allows you to auto consume all the available subscriptions for the Machine.

Alternatively you can specify manually the ID in the pool_id list or a text with all the products that you want to add.

Another interesting option is the parameter customer_id to resume a previous registration.

## Playbook

Live Playbook of how to register a system with Red Hat Subscription-Manager with Ansible playbook

code

``yaml

---

hosts: all

become: true

vars:

subscription_username: "username"

subscription_password: "password"

tasks:

- name: register with subscription-manager

community.general.redhat_subscription:

state: present

username: "{{ subscription_username }}"

password: "{{ subscription_password }}"

auto_attach: true

`

execution

``bash

$ ansible-playbook -i virtualmachines/demo/invento

Read the full tutorial: Register a system with Red Hat Subscription-Manager - Ansible module redhat_subscription