Deploy with Vagrant on KVM/libvirt

In this tutorial i show, how to extend Vagrant, to convert BaseBoxes and deploy to KVM/libvirt.


  • Vagrant installed (min. versionĀ 1.5)

Install Vagrant-Mutate and Vagrant-Libvirt

# Ubuntu, Debian etc.
$ apt-get install qemu-utils libvirt-dev libxslt-dev libxml2-dev zlib1g-dev ruby-dev

# CentOS, Fedora, Red Hat etc.
$ yum install qemu-img libvirt-devel ruby-libvirt ruby-devel libxslt-devel libxml2-devel libguestfs-tools-c

# install Vagrant-Mutate
$ vagrant plugin install vagrant-mutate

# install Vagrant-libvirt
$ vagrant plugin install vagrant-libvirt

Convert existing VirtualBox BaseBox

# Syntax
$ vagrant mutate [box-name | url] [target provider]

# Example for libvirt
$ vagrant mutate lupin/centos7 libvirt

# Show boxes
$ vagrant box list

Supported conversions by Vagrant-mutate

  • VirtualBox to KVM
  • VirtualBox to libvirt
  • libvirt to KVM
  • KVM to libvirt

Vagrantfile example

# -*- mode: ruby -*-

Vagrant.configure("2") do |config|

  config.vm.provider :libvirt do |libvirt| = '<target>'
    libvirt.username = '<user>'
    libvirt.id_ssh_key_file = '<key>'
    libvirt.connect_via_ssh = true

  config.vm.define :my_vm do |machine| = "trusty64" :public_network, :dev => "br0", :mode => 'bridge'

    machine.vm.provider :libvirt do |setting|
      setting.memory = 1024
      setting.cpus = 1
      setting.random_hostname = true



Note: Read the documentation, there are many settings more available!


Common Vagrant commands like: up, destroy, suspend, resume, halt, ssh etc are available.