2021-02-17 12:17:10 +00:00
|
|
|
|
2014-06-04 23:39:58 +00:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
2021-08-14 15:50:50 +00:00
|
|
|
ip = 2
|
|
|
|
machines = [
|
|
|
|
{
|
|
|
|
'iso' => "debian/buster64",
|
|
|
|
'host' => "buster"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'iso' => "generic/ubuntu2004",
|
2021-08-23 01:06:38 +00:00
|
|
|
'host' => "focal"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'iso' => "debian/bullseye64",
|
|
|
|
'host' => "bullseye"
|
2021-08-14 15:50:50 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2014-06-04 23:39:58 +00:00
|
|
|
Vagrant.configure("2") do |config|
|
2020-07-08 18:31:35 +00:00
|
|
|
config.vm.provider :virtualbox do |vb|
|
2021-08-14 15:50:50 +00:00
|
|
|
vb.customize ["modifyvm", :id, "--cpus", 1, "--memory", 512]
|
2020-08-10 02:06:59 +00:00
|
|
|
end
|
|
|
|
config.vm.provider :libvirt do |v|
|
2021-08-14 15:50:50 +00:00
|
|
|
v.memory = 512
|
|
|
|
v.cpus = 1
|
2020-08-10 02:06:59 +00:00
|
|
|
v.nested = true
|
|
|
|
end
|
|
|
|
config.vm.provider :kvm do |kvm|
|
2021-08-14 15:50:50 +00:00
|
|
|
kvm.memory_size = '512m'
|
2020-04-11 18:12:40 +00:00
|
|
|
end
|
2017-01-15 15:47:36 +00:00
|
|
|
|
2014-06-06 12:20:26 +00:00
|
|
|
# Network config: Since it's a mail server, the machine must be connected
|
|
|
|
# to the public web. However, we currently don't want to expose SSH since
|
|
|
|
# the machine's box will let anyone log into it. So instead we'll put the
|
|
|
|
# machine on a private network.
|
2020-08-10 02:06:59 +00:00
|
|
|
config.vm.synced_folder ".", "/vagrant", nfs_version: "3"
|
2014-06-04 23:39:58 +00:00
|
|
|
|
2021-08-23 01:06:38 +00:00
|
|
|
(0..(machines.size - 1)).each do |n|
|
2021-08-14 15:50:50 +00:00
|
|
|
node = machines[n]
|
|
|
|
config.vm.define node['host'] do |m|
|
|
|
|
m.vm.box = node['iso']
|
|
|
|
m.vm.hostname = "#{node['host']}.mailinabox.lan"
|
|
|
|
m.vm.network "private_network", ip: "192.168.168.#{ip+n}"
|
|
|
|
|
|
|
|
m.vm.provision "shell", :inline => <<-SH
|
|
|
|
# Make sure we have IPv6 loopback (::1)
|
|
|
|
sysctl -w net.ipv6.conf.lo.disable_ipv6=0
|
2021-08-23 01:10:34 +00:00
|
|
|
echo -e "fs.inotify.max_user_instances=1024\nnet.ipv6.conf.lo.disable_ipv6=0" > /etc/sysctl.conf
|
2021-08-14 15:50:50 +00:00
|
|
|
# Set environment variables so that the setup script does
|
|
|
|
# not ask any questions during provisioning. We'll let the
|
|
|
|
# machine figure out its own public IP.
|
|
|
|
export NONINTERACTIVE=1
|
|
|
|
export PUBLIC_IP=192.168.168.#{ip+n}
|
|
|
|
export PUBLIC_IPV6=auto
|
|
|
|
export PRIVATE_IP=192.168.168.#{ip+n}
|
|
|
|
export PRIMARY_HOSTNAME=\"#{node['host']}.mailinabox.lan\"
|
|
|
|
export SKIP_NETWORK_CHECKS=1
|
|
|
|
# Start the setup script.
|
|
|
|
cd /vagrant
|
|
|
|
setup/start.sh
|
|
|
|
# After setup is done, fully open the ssh ports again
|
|
|
|
ufw allow ssh
|
|
|
|
SH
|
|
|
|
|
|
|
|
m.vm.provision "shell", run: "always", :inline => <<-SH
|
|
|
|
service mailinabox restart
|
|
|
|
SH
|
|
|
|
end
|
|
|
|
end
|
2021-02-17 12:17:10 +00:00
|
|
|
end
|