GitXplorerGitXplorer
r

docker-vagrant_libvirt_virtualbox

public
5 stars
3 forks
0 issues

Commits

List of commits on branch master.
Verified
f454ecb25179c746e9f782072ce2fa358e32fb06

Use super-linter:slim (#8)

rruzickap committed 3 years ago
Verified
1f82cc9f093a765c6418673b397f4fba49c0818a

Upgrade GH Actions versions (#7)

rruzickap committed 4 years ago
Verified
d484228c64d152580c248c27e94636920ee2d0a0

Fix super-linter configuration (#6)

rruzickap committed 4 years ago
Verified
f7ba09bf3f35b640e5e2cd6ca6dc5235e9f1a3a9

Set version of super-linter and add GITHUB_TOKEN (#5)

rruzickap committed 4 years ago
Verified
66fb8af972601bff4a31fe6119f6c11cc516c721

Replace markdown link checker by action-my-markdown-link-checker (#4)

rruzickap committed 4 years ago
Verified
ff45653944d938873055c1380cdb938ed50283c5

Fix + improve GitHub Actions (#3)

rruzickap committed 5 years ago

README

The README file for this repository.

Dockerfile with Vagrant QEMU and VirtualBox

Docker Hub; peru/vagrant_libvirt_virtualbox Docker pulls Docker Build

This repository provides Dockerfile which can run Vagrant (including vagrant-libvirt and vagrant-winrm plugins) to start / manipulate VM images.

The docker image is primary created for testing Vagrant images built from Packer Templates located in this repository https://github.com/ruzickap/packer-templates.

Installation steps

To use this Docker image you need to install VirtualBox and Docker to your OS (Fedora / Ubuntu). This may work on other operating systems too, but I didn't have a chance to test it.

Ubuntu installation steps (Docker + VirtualBox)

sudo apt update
sudo apt install -y --no-install-recommends docker.io jq libvirt-bin virtualbox wget
sudo gpasswd -a ${USER} docker
# This is mandatory for Ubuntu otherwise docker container will not have access to /dev/kvm - this is default in Fedora (https://bugzilla.redhat.com/show_bug.cgi?id=993491)
sudo bash -c "echo 'KERNEL==\"kvm\", GROUP=\"kvm\", MODE=\"0666\"' > /etc/udev/rules.d/60-qemu-system-common.rules"
sudo sed -i 's/^unix_sock_/#&/' /etc/libvirt/libvirtd.conf
sudo reboot

Fedora installation steps (Docker + VirtualBox)

sudo sed -i 's@^SELINUX=enforcing@SELINUX=disabled@' /etc/selinux/config
sudo dnf upgrade -y
# Reboot if necessary (especially if you upgrade the kernel or related packages)

sudo dnf install -y http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install -y akmod-VirtualBox curl docker git jq kernel-devel-$(uname -r) libvirt-daemon-kvm wget
sudo akmods

sudo bash -c 'echo "vboxdrv" > /etc/modules-load.d/vboxdrv.conf'
sudo usermod -a -G libvirt ${USER}
sudo groupadd docker && sudo gpasswd -a ${USER} docker
sudo systemctl enable docker

sudo reboot

Test box image created from Packer templates

Real example how to use the Docker image to test box image produced by Packer for libvirt/qemu.

BOXES="windows-10-enterprise-x64-eval ubuntu-18.04-server-amd64"

mkdir vagrant_box
cd vagrant_box

for BOX in $BOXES; do
  CURRENT_VERSION=$(curl -s https://app.vagrantup.com/api/v1/box/peru/$BOX | jq -r ".current_version.version")
  wget -c https://app.vagrantup.com/peru/boxes/$BOX/versions/$CURRENT_VERSION/providers/libvirt.box -O ${BOX}-libvirt.box
  wget -c https://app.vagrantup.com/peru/boxes/$BOX/versions/$CURRENT_VERSION/providers/virtualbox.box -O ${BOX}-virtualbox.box
done

docker pull peru/vagrant_libvirt_virtualbox

docker run --rm -t -u $(id -u):$(id -g) --privileged --net=host \
-e HOME=/home/docker \
-v /dev/vboxdrv:/dev/vboxdrv \
-v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
-v $PWD:/home/docker/vagrant \
peru/vagrant_libvirt_virtualbox "set -x \
&& vagrant box add windows-10-enterprise-x64-eval-libvirt.box --name=windows-10-enterprise-x64-eval-libvirt --force \
&& vagrant init windows-10-enterprise-x64-eval-libvirt \
&& vagrant up --provider libvirt \
&& vagrant winrm --shell cmd --command 'systeminfo | findstr /B /C:\"OS Name\" /C:\"OS Version\"' \
&& vagrant destroy --force \
&& vagrant box remove windows-10-enterprise-x64-eval-libvirt \
&& virsh --connect=qemu:///system vol-delete --pool default --vol windows-10-enterprise-x64-eval-libvirt_vagrant_box_image_0.img \
&& rm -rvf Vagrantfile .vagrant"

docker run --rm -t -u $(id -u):$(id -g) --privileged --net=host \
-e HOME=/home/docker \
-v /dev/vboxdrv:/dev/vboxdrv \
-v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
-v $PWD:/home/docker/vagrant \
peru/vagrant_libvirt_virtualbox "set -x \
&& vagrant box add windows-10-enterprise-x64-eval-virtualbox.box --name=windows-10-enterprise-x64-eval-virtualbox --force \
&& vagrant init windows-10-enterprise-x64-eval-virtualbox \
&& sed -i '/config.vm.box =/a \ \ config.vm.provider \"virtualbox\" do |v|\n \ \ \ v.gui = false\n\ \ end' Vagrantfile \
&& vagrant up --provider virtualbox \
&& vagrant winrm --shell cmd --command 'systeminfo | findstr /B /C:\"OS Name\" /C:\"OS Version\"' \
&& vagrant destroy --force \
&& vagrant box remove windows-10-enterprise-x64-eval-virtualbox \
&& rm -rvf Vagrantfile .vagrant"

docker run --rm -t -u $(id -u):$(id -g) --privileged --net=host \
-e HOME=/home/docker \
-v /dev/vboxdrv:/dev/vboxdrv \
-v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
-v $PWD:/home/docker/vagrant \
peru/vagrant_libvirt_virtualbox "set -x \
&& vagrant box add ubuntu-18.04-server-amd64-libvirt.box --name=ubuntu-18.04-server-amd64-libvirt --force \
&& vagrant init ubuntu-18.04-server-amd64-libvirt \
&& vagrant up --provider libvirt \
&& vagrant ssh --command 'grep PRETTY_NAME /etc/os-release; id' \
&& vagrant destroy --force \
&& vagrant box remove ubuntu-18.04-server-amd64-libvirt \
&& virsh --connect=qemu:///system vol-delete --pool default --vol ubuntu-18.04-server-amd64-libvirt_vagrant_box_image_0.img \
&& rm -rf Vagrantfile .vagrant"

docker run --rm -t -u $(id -u):$(id -g) --privileged --net=host \
-e HOME=/home/docker \
-v /dev/vboxdrv:/dev/vboxdrv \
-v /var/run/libvirt/libvirt-sock:/var/run/libvirt/libvirt-sock \
-v $PWD:/home/docker/vagrant \
peru/vagrant_libvirt_virtualbox "set -x \
&& vagrant box add ubuntu-18.04-server-amd64-virtualbox.box --name=ubuntu-18.04-server-amd64-virtualbox --force \
&& vagrant init ubuntu-18.04-server-amd64-virtualbox \
&& sed -i '/config.vm.box =/a \ \ config.vm.provider \"virtualbox\" do |v|\n \ \ \ v.gui = false\n\ \ end' Vagrantfile \
&& vagrant up --provider virtualbox \
&& vagrant ssh --command 'grep PRETTY_NAME /etc/os-release; id' \
&& vagrant destroy --force \
&& vagrant box remove ubuntu-18.04-server-amd64-virtualbox \
&& ls -la && pwd \
&& rm -rvf Vagrantfile .vagrant"