-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVagrantfile
61 lines (51 loc) · 1.51 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
$addrs = {
"manager1" => "192.168.50.2",
"worker1" => "192.168.50.3",
"worker2" => "192.168.50.4"
}
$prov_base = <<-SCRIPT
/vagrant/scripts/enable-swap-limit.sh
/vagrant/scripts/install-deps.sh
pip3 install -U -e /vagrant[dev]
/vagrant/scripts/install-docker.sh
/vagrant/scripts/build-image.sh
/vagrant/scripts/install-pumba.sh
SCRIPT
$prov_env = <<-SCRIPT
tee "/etc/profile.d/custom.sh" <<EOF
export IP_MANAGER1=#{$addrs["manager1"]}
export IP_WORKER1=#{$addrs["worker1"]}
export IP_WORKER2=#{$addrs["worker2"]}
EOF
SCRIPT
$prov_swarm_init = <<-SCRIPT
docker swarm init --advertise-addr #{$addrs["manager1"]}
SCRIPT
unless Vagrant.has_plugin?("vagrant-reload")
system("vagrant plugin install vagrant-reload")
end
Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.provider "virtualbox" do |v|
v.memory = 4096
v.cpus = 2
end
config.vm.provision "shell", inline: $prov_env, run: "always"
config.vm.provision "shell", inline: $prov_base
config.vm.define "manager1", primary: true do |c|
c.vm.hostname = "manager1"
c.vm.network "private_network", ip: $addrs["manager1"]
c.vm.provision "shell", inline: $prov_swarm_init
c.vm.provision :reload
end
config.vm.define "worker1" do |c|
c.vm.hostname = "worker1"
c.vm.network "private_network", ip: $addrs["worker1"]
c.vm.provision :reload
end
config.vm.define "worker2" do |c|
c.vm.hostname = "worker2"
c.vm.network "private_network", ip: $addrs["worker2"]
c.vm.provision :reload
end
end