-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vagrantfile
58 lines (53 loc) · 1.96 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
# -*- mode: ruby -*-
# # vi: set ft=ruby :
# Config parameters
$image_version = "ubuntu/bionic64"
$enable_serial_logging = false
$vm_gui = false
$vm_memory_master = ENV.fetch('VAGRANT_MASTER_RAM', 2048).to_i
$vm_memory_worker = ENV.fetch('VAGRANT_WORKER_RAM', 2048).to_i
$vm_cpus_master = ENV.fetch('VAGRANT_MASTER_CPU', 1).to_i
$vm_cpus_worker = ENV.fetch('VAGRANT_WORKER_CPU', 1).to_i
$default_subnet = ENV.fetch('VAGRANT_SUBNET', '192.168.66.0')
$default_workers = ENV.fetch('VAGRANT_WORKERS', 1).to_i
$subnet_ip = "#{$default_subnet.split(%r{\.\d*$}).join('')}"
$master_ip = $subnet_ip + ".100"
Vagrant.configure("2") do |config|
# Master
config.vm.define "master" do |master_conf|
master_conf.vm.box = $image_version
master_conf.vm.provider :virtualbox do |v|
v.check_guest_additions = false
end
master_conf.vm.define vm_name = "master" do |config|
config.vm.hostname = "master"
config.vm.provider :virtualbox do |vb|
vb.gui = $vm_gui
vb.memory = $vm_memory_master
vb.cpus = $vm_cpus_master
end
end
master_conf.vm.network :private_network, ip: $master_ip
master_conf.vm.provision :shell, :path => "common.sh"
master_conf.vm.provision :shell, :path => "master.sh", :args => "--subnet "+$subnet_ip
end
# Worker config
(1..$default_workers).each do |i|
config.vm.define "worker-#{i}" do |worker_conf|
worker_conf.vm.box = $image_version
worker_conf.vm.provider :virtualbox do |v|
v.check_guest_additions = false
end
worker_conf.vm.hostname = "worker-#{i}"
worker_conf.vm.provider :virtualbox do |vb|
vb.gui = $vm_gui
vb.memory = $vm_memory_worker
vb.cpus = $vm_cpus_worker
end
ip = $subnet_ip + "." + "#{i+150}"
worker_conf.vm.network :private_network, ip: ip
worker_conf.vm.provision :shell, :path => "common.sh"
worker_conf.vm.provision :shell, :path => "worker.sh", :args => "--subnet "+$subnet_ip
end
end
end