DevOps Box: Vagrant with KVM

Configure Vagrant with KVM (Ubuntu)

Installation Steps

Prerequisite Tools

sudo apt install curl xml2

Installing KVM and libvirt

sudo apt-get install -y \
bridge-utils \
cpu-checker \
libguestfs-tools \
libvirt-clients \
libvirt-dev \
qemu-kvm \

Installing Vagrant

Installing vagrant-libvirt Plugin

sudo cp /etc/apt/sources.list /etc/apt/sources.list~
sudo sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list
sudo apt-get update
sudo apt-get build-dep vagrant ruby-libvirt
sudo apt-get install \
dnsmasq-base \
lebtables \
libvirt-dev \
libxml2-dev \
libxslt-dev \
qemu \
ruby-dev \
vagrant plugin install vagrant-libvirt

Testing Vagrant Box

vagrant box add generic/ubuntu2004 --provider libvirt
cat <<-VAGRANTFILE > Vagrantfile
Vagrant.configure("2") do |config| = "generic/ubuntu2004"
vagrant up --provider libvirt
vagrant ssh

System Info

sudo apt install -y inxi neofetch
inxi --system --machine --cpu --network --disk --info

Vagrant Features

Setup Synced Folders

vagrant reload
ssh vagrant@ \
-i .vagrant/machines/default/libvirt/private_key
vagrant destroy


Tool Homepages


Vagrant Libvirt Boxen

Networking Articles

Concluding Thoughts

Linux NinjaPants Automation Engineering Mutant — exploring DevOps, Kubernetes, CNI, IAC

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store