-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
61 lines (50 loc) · 2.1 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
require "yaml"
settings = YAML.load_file "config.yaml"
cluster_name = settings['cluster-name']
Vagrant.configure("2") do |config|
config.vm.box = settings['box']
config.vm.box_check_update = false
config.vm.synced_folder ".", "/vagrant", create: true
config.vm.provider "virtualbox" do |vb|
vb.linked_clone = true
vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
vb.customize ["modifyvm", :id, "--groups", ("/" + cluster_name)]
vb.cpus = "2"
vb.memory = "1024"
end
config.vm.provision "shell", inline: "sudo cp /vagrant/scripts/sources.list /etc/apt/sources.list"
# controllers
config.vm.define settings['controller']['hostname'] do |controller|
controller.vm.hostname = settings['controller']['hostname']
controller.vm.network "private_network", ip: settings['controller']['ip']
controller.vm.provider "virtualbox" do |vb|
vb.name = cluster_name + "_" + settings['controller']['hostname']
end
controller.vm.provision "base", type: "shell", path: "scripts/base.sh"
if settings['mtls']['enabled'] == true
controller.vm.provision "mtls", type: "shell", inline: "sudo bash /vagrant/scripts/mtls_controller.sh"
end
controller.vm.provision "controller", type: "shell", path: "scripts/controller.sh"
end
# satellites
settings['satellites']['nodes'].each do |sat|
config.vm.define sat["hostname"] do |node|
node.vm.hostname = sat['hostname']
node.vm.network "private_network", ip: sat['ip']
# disks
sat['disks'].each do |disk|
node.vm.disk :disk, name: disk['name'], size: disk['size']
end
node.vm.provider "virtualbox" do |vb|
vb.name = cluster_name + "_" + sat['hostname']
end
node.vm.provision "base", type: "shell", path: "scripts/base.sh"
if settings['mtls']['enabled'] == true
node.vm.provision "mtls", type: "shell", inline: "sudo bash /vagrant/scripts/mtls_satellite.sh"
end
node.vm.provision "satellite", type: "shell", env: {
"CONTROLLERS" => settings['controller']['ip'],
}, path: "scripts/satellite.sh"
end
end
end