Vagrant Quickstart on Ubuntu Xenial 16.04 with Libvirt

There’s a few issues with running Vagrant with Libvirt on Ubuntu 16.04 .  Namely, the bundled version of Vagrant is broken.  Whoops!

Here’s how you can get it running using the upstream Vagrant (currently 1.8.4), get a basic libvirt running, and bring up a VM just to prove that it works (we’ll use openSUSE because they provide a box that works with libvirt).

Install the libvirt essentials

sudo apt-get update
sudo apt-get install ubuntu-virt-server ubuntu-virt-mgmt virt-manager libvirt-dev
sudo adduser YOURUSERNAME libvirtd

Fetch and install upstream Vagrant

DANGER:  Don’t run any vagrant plugins with sudo, it will probably trash permissions on your ~/.vagrant.d/ directory and go badly for you.

sudo apt purge vagrant
sudo apt autoremove
sudo dpkg -i vagrant_1.8.4_x86_64.deb
sudo apt-get install -f
vagrant plugin install vagrant-libvirt

Bring up a test VM

Showtime!  Bring up a test VM and connect to it with ssh…

mkdir testvm
cd testvm
vagrant init opensuse/openSUSE-42.1-x86_64
vagrant up --provider libvirt
vagrant ssh

Get rid of the test machine

vagrant destroy

Phew.  Next up, making your own box.