RHEL 7 with Vagrant and KVM

A short how-to on setting up a RHEL 7 virtual machine with Vagrant and libvirt (KVM) on Fedora 23.

Vagrant is computer software that creates and configures virtual development environments. It can be seen as a higher-level wrapper around virtualization software such as VirtualBox, VMware, KVM and Linux Containers (LXC), and around configuration management software such as Ansible, Chef, Salt, and Puppet. —Wikipedia

Requirements

Install Vagrant and the libvirt provider

First you will need to install Vagrant and the libvirt provider :

yum install -y vagrant vagrant-libvirt

Download and add the RHEL Vagrant box

Download both the RHEL 7.2 Vagrant box for libvirt and the Red Hat Container Tools from access.redhat.com. The Red Hat Container Tools contains the registration plugin that is needed to automate the process of registering a subscription.

Install the registration plugin in Vagrant :

unzip cdk-*.zip && cd cdk/plugins
vagrant plugin install vagrant-registration

Add the downloaded RHEL box to Vagrant :

vagrant box add rhel/7.2 file://rhel-cdk-kubernetes-7.2-23.x86_64.vagrant-libvirt.box

Enable the subscription registration

Create your VagrantFile :

vagrant init rhel/7.2

Edit the VagrantFile you just created and add the following to it :

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

Launch your virtual machine

Start your virtual machine with the following command :

vagrant up

Done!


© 2024. All rights reserved.