AnsiblePilot — Master Ansible Automation
AnsiblePilot is the leading resource for learning Ansible automation, DevOps, and infrastructure as code. Browse over 1,100 tutorials covering Ansible modules, playbooks, roles, collections, and real-world examples. Whether you are a beginner or an experienced engineer, our step-by-step guides help you automate Linux, Windows, cloud, containers, and network infrastructure.
Popular Topics
About Luca Berton
Luca Berton is an Ansible automation expert, author of "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example" published by Apress, and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.
Ansible subscription-manager: Register RHEL with redhat_subscription Module — Video Tutorial
How to register RHEL systems with Red Hat Subscription-Manager using Ansible. Automate registration, pool assignment, and package installation with examples.
What You'll Learn
- How to register a system with Red Hat Subscription-Manager with Ansible?
- Ansible register a system with Red Hat Subscription-Manager
- Parameters
- code
- execution
- before execution
- after execution
- Conclusion
- Related Articles
Full Tutorial Content
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
- pool _string_ - '^(Red Hat Enterprise Server|Red Hat Virtualization)$'
- consumer_id _string_ - resume a previous registration
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
- subscription-manager.yml
```yaml
---
- name: subscription-manager module Playbook
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/inventory register\ RedHat\ subscription/subscription_manager.yml
PLAY [subscription-manager module Playbook] ***********************************************************
TASK [Gathering Facts] ****************************************************************************
ok: [demo.example.com]
TASK [register with subscription-manager] *********************************************************
changed: [demo.example.com]
PLAY RECAP ****************************************************************************************
dem
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 6 min
- Category: installation
Read the full written article: Ansible subscription-manager: Register RHEL with redhat_subscription Module
Related Video Tutorials
- Ansible Set File Permissions 755: chmod with file Module Guide — How to set file permissions with Ansible file module. Add execute permission (755, 644, 600), manage ownership, and apply permissions recursively.
- Ansible Core 2.14.2 & Community 7.2.0: Latest Updates — Discover the latest updates for Ansible Core 2.14.2 and Community 7.2.0. Learn about new features, installation tips, and how these releases impact your automation.
- Ansible Core 2.14.3, 2.13.8 & Community 7.3.0: Updates — Explore the latest bug-fix releases of Ansible Core 2.14.3, 2.13.8, and Community 7.3.0. Get installation tips and insights into new features and improvements.
- Ansible Core 2.14.4 & Community 7.4.0: Latest Updates — Discover the new bug-fix releases for Ansible Core 2.14.4 and Community 7.4.0. Find out about improvements, installation tips, and upcoming features.
- Ansible Core 2.15.0 Beta 3 Released: Key Updates — Discover the latest Ansible Core 2.15.0 beta 3 release, featuring new modules and performance improvements. No Ansible Community release this time.
- Ansible Core 2.15.0 Released: New Features & Changes — Discover Ansible Core 2.15.0's latest features, improvements, and breaking changes. Includes new modules and key updates for better performance.