Here’s a quick playbook to subscribe a host, or hosts to the Red Hat Network. Because I use subscription-manager commands so infrequently, I always have to look up usage in the man page first. Now I just run this playbook instead:
---
- name: Subscribe {{ ansible_hostname }} to Red Hat network
hosts: all
# Requires ansible vault containing rhn username and password
vars_files:
vars/rhn_user.yml
tasks:
- name: Subscibe to RHN
redhat_subscription:
state: present
username: "{{ rhn_user }}"
password: "{{ rhn_password }}"
auto_attach: true
Don’t forget to create an ansible vault containing rhn_user and rhn_password, and to run ansible-playbook with the –ask-vault-pass switch.
One thought on “Ansible: Subscribe to Red Hat Network”