-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathVagrantfile
168 lines (132 loc) · 5.42 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
156
157
158
159
160
161
162
163
164
165
166
167
168
HOST_ONLY_NETWORK = "vboxnet1" # Typically on Linux/Mac
#HOST_ONLY_NETWORK = "VirtualBox Host-Only Ethernet Adapter #2" # Typically on Windows
Vagrant.configure("2") do |config|
config.vm.define "companyrouter" do |host|
host.vm.box = "almalinux/9"
host.vm.hostname = "companyrouter"
host.vm.network "private_network", ip: "192.168.62.253", netmask: "255.255.255.0", name: HOST_ONLY_NETWORK
host.vm.network "private_network", ip: "172.30.255.254", netmask: "255.255.0.0", virtualbox__intnet: "internal-company-lan"
host.vm.provider :virtualbox do |v|
v.name = "companyrouter"
v.cpus = "1"
v.memory = "1024"
end
host.vm.provision "shell", inline: <<-SHELL
# Default gateway
nmcli connection modify "System eth1" ipv4.gateway 192.168.62.254
systemctl restart NetworkManager
SHELL
end
config.vm.define "dns" do |host|
host.vm.box = "generic/alpine318"
host.vm.hostname = "dns"
host.vm.network "private_network", ip: "172.30.0.4", netmask: "255.255.255.0", virtualbox__intnet: "internal-company-lan"
host.vm.provider :virtualbox do |v|
v.name = "dns"
v.cpus = "1"
v.memory = "256"
end
host.vm.provision "shell", inline: <<-SHELL
# For ansible
apk --no-cache add python3
# Default gateway
echo "gateway 172.30.255.254" >> /etc/network/interfaces
service networking restart
SHELL
end
config.vm.define "web" do |host|
host.vm.box = "almalinux/9"
host.vm.hostname = "web"
host.vm.network "private_network", ip: "172.30.0.10", netmask: "255.255.255.0", virtualbox__intnet: "internal-company-lan"
host.vm.provider :virtualbox do |v|
v.name = "web"
v.cpus = "1"
v.memory = "1024"
end
host.vm.provision "shell", inline: <<-SHELL
# Default gateway
nmcli connection modify "System eth1" ipv4.gateway 172.30.255.254
systemctl restart NetworkManager
SHELL
end
config.vm.define "database" do |host|
host.vm.box = "generic/alpine318"
host.vm.hostname = "database"
host.vm.network "private_network", ip: "172.30.0.15", netmask: "255.255.255.0", virtualbox__intnet: "internal-company-lan"
host.vm.provider :virtualbox do |v|
v.name = "database"
v.cpus = "1"
v.memory = "256"
end
host.vm.provision "shell", inline: <<-SHELL
# For ansible
apk --no-cache add python3
# Default gateway
echo "gateway 172.30.255.254" >> /etc/network/interfaces
service networking restart
SHELL
end
config.vm.define "employee" do |host|
host.vm.box = "generic/alpine318"
host.vm.hostname = "employee"
# TODO DHCP
host.vm.network "private_network", ip: "172.30.0.123", netmask: "255.255.255.0", virtualbox__intnet: "internal-company-lan"
host.vm.provider :virtualbox do |v|
v.name = "employee"
v.cpus = "1"
v.memory = "256"
end
host.vm.provision "shell", inline: <<-SHELL
# For ansible
apk --no-cache add python3
# Default gateway
echo "gateway 172.30.255.254" >> /etc/network/interfaces
service networking restart
SHELL
end
config.vm.define "isprouter" do |host|
host.vm.box = "generic/alpine318"
host.vm.hostname = "isprouter"
host.vm.network "private_network", ip: "192.168.62.254", netmask: "255.255.255.0", name: HOST_ONLY_NETWORK
host.vm.provider :virtualbox do |v|
v.name = "isprouter"
v.cpus = "1"
v.memory = "256"
end
host.vm.provision "shell", inline: <<-SHELL
apk --no-cache add python3 # For ansible
SHELL
host.vm.provision "file", source: "ansible", destination: "$HOME/ansible"
end
config.vm.define "homerouter" do |host|
host.vm.box = "almalinux/9"
host.vm.hostname = "homerouter"
host.vm.network "private_network", ip: "192.168.62.42", netmask: "255.255.255.0", name: HOST_ONLY_NETWORK
host.vm.network "private_network", ip: "172.10.10.254", netmask: "255.255.255.0", virtualbox__intnet: "employee-home-lan"
host.vm.provider :virtualbox do |v|
v.name = "homerouter"
v.cpus = "1"
v.memory = "1024"
end
host.vm.provision "shell", inline: <<-SHELL
# Default gateway
nmcli connection modify "System eth1" ipv4.gateway 192.168.62.254
systemctl restart NetworkManager
SHELL
end
config.vm.define "remote-employee" do |host|
host.vm.box = "almalinux/9"
host.vm.hostname = "remote-employee"
host.vm.network "private_network", ip: "172.10.10.123", netmask: "255.255.255.0", virtualbox__intnet: "employee-home-lan"
host.vm.provider :virtualbox do |v|
v.name = "remote-employee"
v.cpus = "1"
v.memory = "1024"
end
host.vm.provision "shell", inline: <<-SHELL
# Default gateway
nmcli connection modify "System eth1" ipv4.gateway 172.10.10.254
systemctl restart NetworkManager
SHELL
end
end