While fixing bugs and testing patches, I often use virtual machines running RHEL. These systems are short living, and normally do not survive a day or two. For most tests and development tries, I have little need to install additional packages or updates. An installation from the DVD contains all that is needed. Mostly...
To install additional packages or updates, it is needed to register the system to the Red Hat Customer Portal. The subscription-manager tool that is installed on all current RHEL systems can be used for that. For simple usage of the utility, a username and password is sufficient. Automating the subscribing process would require saving those credentials in a kickstart or ansible configuration, that's not what I want. Manually subscribing the VM when I need to was the annoying workaround.
A few weeks ago, I finally took the time to setup my automated RHEL installations to use subscription-manager for registering at the Red Hat Customer Portal. The Customer Portal offers the possibility to configure Activation Keys. The subscription-manager tool can use this key with a command like this:
# subscription-manager register \ --org 123456 \ --activationkey my-rhel-example-key # subscription-manager attach --auto
The --org option seems required for me. I am not sure everyone needs that. The number (or name) can be found on an installed and registered system but executing:
# subscription-mananger identity
After subscribing like the above, it may well be that many repositories/channels get enabled. If you know which repositories you need, you can disable all repositories, and enable a select few:
# subscription-manager repos \ --disable '*' # subscription-manager repos \ --enable rhel-7-server-rpms \ --enable rhel-7-server-optional-rpms
At the moment, I have this done in the %post section of my kickstart configuration. I would prefer to set this up with the redhat_subscription ansible module, but the --org option is not available there (yet?).