jwhited-wgsd/vagrant/Vagrantfile
2021-01-11 15:14:35 +01:00

54 lines
1.4 KiB
Ruby

# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.trigger.before :up do |trigger|
trigger.run = {inline: "cp -uvf ../../../../../bin/coredns ../../../../../bin/wgsd-client ."}
end
config.vm.box = "ubuntu/focal64"
config.vm.synced_folder ".", "/vagrant", type: "rsync"
config.vm.provision "shell", inline: <<-SHELL
apt-get -y update
apt-get -y install wireguard
SHELL
config.vm.define "registry" do |registry|
registry.vm.hostname = "registry"
registry.vm.network "private_network", ip: "192.168.33.10"
registry.vm.provision "shell", inline: <<-SHELL
wg genkey | tee /etc/wireguard/privatekey | wg pubkey | tee /etc/wireguard/publickey
cat > /etc/wireguard/wg0.conf << EOF
[Interface]
PrivateKey = $(cat /etc/wireguard/privatekey)
Address = 192.168.100.10/24
SaveConfig = True
ListenPort = 51820
EOF
chmod 600 /etc/wireguard/{privatekey,wg0.conf}
chmod 644 /etc/wireguard/publickey
chmod 711 /etc/wireguard
systemctl enable wg-quick@wg0
systemctl start wg-quick@wg0
cat > /etc/rc.local << EOF
#!/bin/sh
/vagrant/coredns -conf /vagrant/Corefile | logger &
EOF
chmod 755 /etc/rc.local
sleep 1
/etc/rc.local
SHELL
end
(1..4).each do |i|
config.vm.define "client-#{i}" do |client|
client.vm.hostname = "client-#{i}"
client.vm.network "private_network", ip: "192.168.33.10#{i}"
end
end
end