Developing/testing vagrant-libvirt

This is a draft I update on the go.

My goal is to make Vagrant work with QEMU/KVM using libvirt and this is a development quickstart for vagrant-libvirt plugin which does exactly that and which I plan to improve.

Vagrant

Download and install vagrant package.

vagrant-libvirt

Lives on github.

Nice README

install

git clone https://github.com/pradels/vagrant-libvirt.git
cd vagrant-libvirt
# dependencies on Fedora 18
sudo yum install -y libvirt gcc rubygem-bundler
sudo yum install -y libxml2-devel libxslt-devel libvirt-devel libffi-devel
bundle install

create box

A box is a tarball containing:

  • qcow2 image file named box.img.
  • metadata.json file describing box image (provider, virtual_size, format).
  • Vagrantfile that does default settings for the provider-specific configuration for this provider.

vagrant-libvirt git contains example_box:

cp -r vagrant-libvirt/example_box my_box
cd my_box
# get qcow image
wget -O box.img "https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img"
# From example_box/README.md:
edit metadata.json
tar cvzf my_box.box ./metadata.json ./Vagrantfile ./box.img
vagrant box add my_box my_box.box

develop

You can test the plugin without installing it into your Vagrant environment by creating a Vagrantfile in vagrant-libvirt directory and add as a first line

Vagrant.require_plugin "vagrant-libvirt"

Minimal vagrant-libvirt/Vagrantfile:

Vagrant.require_plugin "vagrant-libvirt"

Vagrant::Config.run do |config|
  config.vm.box = "my_box"
end

With Vagrantfile ready, you can use bundler to execute Vagrant:

bundle exec 'vagrant up --provider=libvirt'

fail

Sadly, previous command fails for me with

Bringing machine 'default' up with 'libvirt' provider...
Error while connecting to libvirt: Error making a connection to libvirt URI qemu://localhost/system?no_verify=1:
Call to virConnectOpen failed: Cannot read CA certificate '/etc/pki/CA/cacert.pem': No such file or directory

I wasn’t able to make it work even after Genereating libvirt certificates.

blogroll

social