GitXplorerGitXplorer
r

docker-vagrant_libvirt_virtualbox

public
5 stars
3 forks
0 issues

Commits

List of commits on branch master.
Verified
0a0b37fc5270c582fb5fb35043bab5b382664c01

Add super-linter + fix related issues (#2)

rruzickap committed 5 years ago
Unverified
04f157bd78efbd17cd0a2300fb25a0ad2f8aaef4

Fix issue with Oracle license "auto-accept"

rruzickap committed 5 years ago
Unverified
262dbddd41b4aa51440d14db0dd677475786ebd1

Update ubuntu from ubuntu-18.04 -> ubuntu-latest

rruzickap committed 5 years ago
Unverified
ad8b59632ddffe7b7051c6e097cad2b91d47d0ac

Update github-action-markdown-link-check to version v1

rruzickap committed 5 years ago
Unverified
f23069d228a3c9854716dd60f85b9413a47c0311

Increase version of markdown-link-check and use action-yamllint with tag

rruzickap committed 5 years ago
Unverified
4e8790fc6db28120b608d73cf5023d0058fa55f1

Add comments to .yamllint.yml

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"