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-daemon-system
libvirt-dev \
qemu-kvm \
virt-manager

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 \
zlib1g-dev
vagrant plugin install vagrant-libvirt

Testing Vagrant Box

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

System Info

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

Vagrant Features

Setup Synced Folders

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

Resources

Tool Homepages

Installation

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