-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
executable file
·87 lines (83 loc) · 2.48 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
ENV['VAGRANT_EXPERIMENTAL'] = "disks"
VAGRANTFILE_API_VERSION = "2"
servers = {
"dev-gluster-01" => {
:script => "provision-gluster-server.sh",
:ip => "192.168.10.10",
:cpus => 2,
:memory => 2048,
:disks => [
{
name: "data",
size: "20GB"
}
]
},
"dev-gluster-02" => {
:script => "provision-gluster-server.sh",
:ip => "192.168.10.20",
:cpus => 2,
:memory => 2048,
:disks => [
{
name: "data",
size: "20GB"
}
]
},
"dev-gluster-03" => {
:script => "provision-gluster-server.sh",
:ip => "192.168.10.30",
:cpus => 2,
:memory => 2048,
:disks => [
{
name: "data",
size: "20GB"
}
]
},
"dev-client-01" => {
:script => "provision-gluster-client.sh",
:ip => "192.168.10.40",
:cpus => 2
}
}
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
servers.each do |hostname, server|
config.vm.define hostname do |cfg|
cfg.vm.provider "virtualbox" do |vb|
vb.check_guest_additions = false
vb.default_nic_type = "virtio"
vb.customize ["modifyvm", :id, "--cpus", server[:cpus] || 1]
vb.customize ["modifyvm", :id, "--memory", server[:memory] || 768]
vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
vb.customize ["modifyvm", :id, "--audio", "none"]
vb.customize ["modifyvm", :id, "--uart1", "off"]
vb.customize ["modifyvm", :id, "--uartmode1", "disconnected"]
end
cfg.vm.box = "ubuntu/focal64"
cfg.vm.hostname = hostname
# virtualbox__intnet allows servers to communicate with eachother using the VirtualBox internal network
cfg.vm.network "private_network", ip: server[:ip], virtualbox__intnet: true
# virtualbox__hostonly allows the host to connect to VirtualBox machines
cfg.vm.network "private_network", type: "dhcp", virtualbox__hostonly: true
if server[:disks]
server[:disks].each do |disk|
cfg.vm.disk :disk, size: disk[:size], name: disk[:name], primary: disk[:primary] || false
end
end
if server[:forwarded_ports]
server[:forwarded_ports].each do |port|
cfg.vm.network "forwarded_port", guest: port[:guest], host: port[:host], auto_correct: true
end
end
cfg.vm.provision "shell", path: "provision-common.sh"
if server[:script]
cfg.vm.provision "shell", path: server[:script]
end
end
end
end