-
Notifications
You must be signed in to change notification settings - Fork 22
/
Vagrantfile
155 lines (122 loc) · 4.69 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
# NOTE: Netmask is assumed 255.255.255.0 for all
SERVER1_TUNNEL_IP = "192.168.1.10"
SERVER1_TUNNEL_GATEWAY = "192.168.1.254"
SERVER1_MGMT_IP = "192.168.101.10"
SERVER2_TUNNEL_IP = "192.168.2.20"
SERVER2_TUNNEL_GATEWAY = "192.168.2.254"
SERVER2_MGMT_IP = "192.168.101.20"
INTERNET_MGMT_IP = "192.168.101.254"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty64"
# "INTERNET"
config.vm.define "internet" do |server|
server.vm.hostname = "internet"
# Server 1 tunnel transport network
server.vm.network "private_network",
virtualbox__intnet: "server1_net",
ip: SERVER1_TUNNEL_GATEWAY,
netmask: "255.255.255.0"
# Server 2 tunnel transport network
server.vm.network "private_network",
virtualbox__intnet: "server2_net",
ip: SERVER2_TUNNEL_GATEWAY,
netmask: "255.255.255.0"
# Management/Control network
server.vm.network "private_network",
ip: INTERNET_MGMT_IP,
netmask: "255.255.255.0"
server.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", 256]
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
server.vm.provision "shell", inline: <<-SCRIPT
[ "$(sysctl --values net.ipv4.ip_forward)" -eq "1" ] || {
# Persist across reboots
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf # enable ip4 forwarding
sysctl -p # apply settings from /etc/sysctl.conf
}
SCRIPT
server.vm.provision "puppet" do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "site.pp"
puppet.options = "--verbose --debug"
end
end
# SERVER 1
config.vm.define "server1" do |server|
server.vm.hostname = "server1"
# Tunnel transport network
server.vm.network "private_network",
virtualbox__intnet: "server1_net",
ip: SERVER1_TUNNEL_IP,
netmask: "255.255.255.0",
auto_config: false
# Provision tunnel transport interface via file, so we can
# add a persistent static route to tunnel gateway
server.vm.provision "shell", inline: <<-SCRIPT
[ -e /etc/network/interfaces.d/eth1.cfg ] || {
cat << EOT >/etc/network/interfaces.d/eth1.cfg
auto eth1
iface eth1 inet static
address #{SERVER1_TUNNEL_IP}
netmask 255.255.255.0
up ip route add #{SERVER2_TUNNEL_IP}/32 via #{SERVER1_TUNNEL_GATEWAY} dev eth1
EOT
ifup eth1
}
SCRIPT
# Management/Control network
server.vm.network "private_network",
ip: SERVER1_MGMT_IP,
netmask: "255.255.255.0"
server.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", 256]
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
server.vm.provision "puppet" do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "site.pp"
puppet.options = "--verbose --debug"
end
end
# SERVER 2
config.vm.define "server2" do |server|
server.vm.hostname = "server2"
# Tunnel transport network
server.vm.network "private_network",
virtualbox__intnet: "server2_net",
ip: SERVER2_TUNNEL_IP,
netmask: "255.255.255.0",
auto_config: false
# Provision tunnel transport interface via file, so we can
# add a persistent static route to tunnel gateway
server.vm.provision "shell", inline: <<-SCRIPT
[ -e /etc/network/interfaces.d/eth1.cfg ] || {
cat << EOT >/etc/network/interfaces.d/eth1.cfg
auto eth1
iface eth1 inet static
address #{SERVER2_TUNNEL_IP}
netmask 255.255.255.0
up ip route add #{SERVER1_TUNNEL_IP}/32 via #{SERVER2_TUNNEL_GATEWAY} dev eth1
EOT
ifup eth1
}
SCRIPT
# Management/Control network
server.vm.network "private_network",
ip: SERVER2_MGMT_IP,
netmask: "255.255.255.0"
server.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", 256]
vb.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
end
server.vm.provision "puppet" do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "site.pp"
puppet.options = "--verbose --debug"
end
end
end