Notes to self

Use your RHEL Vagrant boxes as any other with vagrant-registration

vagrant-registration plugin for Vagrant allows developers to easily register their guests for updates on systems with a subscription model like Red Hat Enterprise Linux. Here is how to install the plugin and set it up.

You can install vagrant-registration plugin as:

$ vagrant plugin install vagrant-registration

Note that on Fedora, we have it packaged:

$ sudo dnf install vagrant-registration

After installation you are able to update your project’s Vagrantfile (or global Vagrantfile for every project as I already mentioned):

$ cat Vagrantfile
if Vagrant.has_plugin?('vagrant-registration')
  config.registration.username = 'foo'
  config.registration.password = 'bar'

# Alternatively
if Vagrant.has_plugin?('vagrant-registration') = 'foo'
  config.registration.activationkey = 'bar'

As you can see, you can either choose username/password or org/activationkey combinations to register your RHEL box. This will run subscription-manager register on vagrant up and unregister on vagrant halt and vagrant destroy.

You can even choose to unregister only on destroy:

config.registration.unregister_on_halt = false

or skip registration altogether:

config.registration.skip = true

You need to explicitly skip registration because otherwise the plugin will prompt you for your username/password input interactively.

If you need to pass more options to subscription-manager register, vagrant-registration supports all the options of register command. By default it appends --force and --auto-attach flags.

Also support for other systems such as SLES would be very easy to add, but I don’t have the subscription to properly test it. Perhaps some of you can help?

by Josef Strzibny