Add a demo using Vagrant

Adds a demo using a Vagrantfile to connect a VM to the host's network,
and a script to start the Docker container and the VM together.
This commit is contained in:
Sam Mesterton-Gibbons 2020-05-11 11:52:57 +01:00
parent 68fd14c7a2
commit 07005bcf51
4 changed files with 55 additions and 0 deletions

1
.dockerignore Normal file
View file

@ -0,0 +1 @@
vagrant-demo/

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
vagrant-demo/.vagrant

26
vagrant-demo/Vagrantfile vendored Normal file
View file

@ -0,0 +1,26 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "clink15/pxe"
# Bridge the VM onto your host's network
config.vm.network "public_network"
# Don't wait for VM to boot - it won't finish anyway
config.vm.boot_timeout = 5
config.vm.provider "virtualbox" do |vb|
# Display the GUI so we can see what it does
vb.gui = true
# Add enough RAM to download Ubuntu live
vb.memory = 5120
# Enable PXE boot as the only option
vb.customize ["modifyvm", :id, "--boot1", "net"]
# Disconnect the default NIC
vb.customize ["modifyvm", :id, "--nic1", "none"]
end
end

27
vagrant-demo/run-demo.sh Executable file
View file

@ -0,0 +1,27 @@
#!/bin/bash
DHCP_RANGE_START=${1:-192.168.0.1}
# Start the netboot container and run it in the background
docker run --net=host -e DHCP_RANGE_START=${DHCP_RANGE_START} samdbmg/dhcp-netboot.xyz &
DOCKER_PROCESS=$!
# Catch ctrl-c and clean up
function cleanup() {
echo "Caught SIGINT, stopping VM"
vagrant destroy -f
echo "Waiting for Docker to stop"
wait ${DOCKER_PROCESS}
exit 0
}
trap cleanup INT
# Bring up the VM - this will fail because Vagrant can't SSH to it, but that's fine
vagrant up || true
# Wait for Ctrl-C
while true; do
sleep 10
done