-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Vagrantfile
75 lines (67 loc) · 2 KB
/
Vagrantfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# -*- mode: ruby -*-
# vi: set ft=ruby :
ip = 2
machines = [
{
'iso' => "debian/buster64",
'host' => "buster"
},
{
'iso' => "generic/ubuntu2004",
'host' => "focal"
},
{
'iso' => "debian/bullseye64",
'host' => "bullseye"
},
{
'iso' => "generic/ubuntu2204",
'host' => "jammy"
},
]
Vagrant.configure("2") do |config|
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--cpus", 1, "--memory", 768]
end
config.vm.provider :libvirt do |v|
v.memory = 768
v.cpus = 1
v.nested = true
end
config.vm.provider :kvm do |kvm|
kvm.memory_size = '768m'
end
# 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.
config.vm.synced_folder ".", "/vagrant", nfs_version: "4"
(0..(machines.size - 1)).each do |n|
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
git config --global --add safe.directory /vagrant
# 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
end