Just moozing

Before you can check your notes, you must make them…

Vagrant and libvirt

with one comment

I have mentioned vagrant before. A show stopper for me has been issues with getting it to work with libvirt. Now there is a plugin for it, so it is time for me to start using it for real.

vagrant logoIn this blog post, I will describe how to combine vagrant and qemu/KVM using libvirt on a Debian/jessie host. We will use the plugin by pradels from github.

Before you can make the vagrant plug-in work, libvirt must be working, e.g. create/start/stop og Qemu/KVM virtual machines must work in virt-manager. Hints are available on the Debian wiki.

 

The quick installation how to of vagrant and plugin

As root, install vagrant (this installs virtualbox also)

apt-get install vagrant

Installing supporting libraries (still as root)

apt-get install libxslt-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev

 

Now you should have everything needed for the user to work with vagrant

Install plugin (as user)

vagrant plugin install vagrant-libvirt

and create the first instance

mkdir vagranttest
cd vagranttest
mkdir data

A minimal Vagrantfile looks like this

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
 config.vm.box = "base"
 config.vm.provider :libvirt do |libvirt|
   libvirt.host = ""
 end
 config.vm.synced_folder "./data", "/vagrant", type: "9p"
end

It will map /vagrant in the virtual machine to vagranttest/data using the 9p file system. This was needed to avoid using NFS, which appears to be daefault.

 

Start it


vagrant up --provider libvirt

 

And you should be able to access it using

vagrant ssh

By now you should have an ordinary virtual KVM virtual machine with ssh access, so you can install whatever software and configuration you need.

 

Closing comments

  • Consider create your own base box. It is not difficult.
  • Vagrantfile can hold lots of configuration and provisioning. Yet another thing to look into.
  • “Vagrant up” can start multiple virtual machines at the same time.
Advertisements

Written by moozing

June 2, 2015 at 12:00

Posted in Tech

Tagged with , ,

One Response

Subscribe to comments with RSS.

  1. […] initial experiences with vagrant and libvirt is found here, so start there for the libvirt […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: