hanneseichblatt.de About Pages Tags Contact RSS

Vagrant with libvirtd on CentOS 7

31 May 2015

Vagrant is a tool to

[c]reate and configure lightweight, reproducible, and portable development environments.

It takes a declarative definition (a Vagrantfile) of a virtual machine and creates that machine for you. Among its supported virtualization technologies are VirtualBox and libvirt. We want to be able to do this on a server running CentOS 7 and use an already installed libvirtd as the provider.

First, we remove any previously installed versions of Vagrant.

yum remove vagrant

We will install Vagrant from the jstribny/vagrant1 COPR which depends on two other COPRs providing the Ruby200 and Ror40 Software Collections. This is the way Fedora Magazine recommended.

cd /etc/yum.repos.d/
wget https://copr.fedoraproject.org/coprs/rhscl/ruby200-el7/repo/epel-7/rhscl-ruby200-el7-epel-7.repo
wget https://copr.fedoraproject.org/coprs/rhscl/ror40-el7/repo/epel-7/rhscl-ror40-el7-epel-7.repo
wget https://copr.fedoraproject.org/coprs/jstribny/vagrant1/repo/epel-7/jstribny-vagrant1-epel-7.repo
yum install vagrant1 vagrant1-vagrant-libvirt

Because we want to use our own default provider instead of VirtualBox, we need to tell Vagrant by setting an environment variable. You may append this into your shell configuration file (or your Vagrantfile).

export VAGRANT_DEFAULT_PROVIDER=libvirt

Now we activate the vagrant1 Software Collection for our current shell.

scl enable vagrant1 $SHELL

Change into the directory containing our Vagrantfile (for example by cloning and entering vagrant-fedora22) and start the VM.

vagrant up