-
Notifications
You must be signed in to change notification settings - Fork 19
/
Vagrantfile
56 lines (49 loc) · 1.93 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
def get_ip(index = 1)
$ip_range.sub('xx', (index).to_s)
end
CONSUL_NOMAD_NODES = 3
# VirtualBox enforces host-only networks to be in the 192.168.56.0/21 IP range
# by default.
$ip_range = '192.168.56.2xx'
$all_nodes = Array.new(CONSUL_NOMAD_NODES).fill { |i| "#{get_ip(i + 1)}" }
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/focal64"
(1..CONSUL_NOMAD_NODES).each do |i|
config.vm.define "consul-nomad-node#{i}" do |node|
node_ip_address = "#{get_ip(i)}"
node.vm.network "private_network", ip: node_ip_address
node.vm.hostname = "consul-nomad-node#{i}"
# Increase memory for Virtualbox
node.vm.provider "virtualbox" do |vb|
vb.memory = "1024"
vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
vb.customize [ "modifyvm", :id, "--uartmode2", "disconnected" ]
vb.customize [ "modifyvm", :id, "--uartmode3", "disconnected" ]
vb.customize [ "modifyvm", :id, "--uartmode4", "disconnected" ]
end
end
end
config.vm.define "loadbalancer" do |lb|
node_ip_address = "#{get_ip(0)}"
lb.vm.network "private_network", ip: node_ip_address
lb.vm.hostname = "loadbalancer"
lb.vm.provider "virtualbox" do |vb|
vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
vb.customize [ "modifyvm", :id, "--uartmode2", "disconnected" ]
vb.customize [ "modifyvm", :id, "--uartmode3", "disconnected" ]
vb.customize [ "modifyvm", :id, "--uartmode4", "disconnected" ]
end
end
config.vm.provision "ansible", type: "ansible", run: "never" do |ansible|
ansible.compatibility_mode = "2.0"
ansible.limit = "all,localhost"
ansible.playbook = "playbook.yml"
ansible.groups = {
"consul_nomad" => (1..CONSUL_NOMAD_NODES).map { |node| "consul-nomad-node#{node}" },
"all:vars" => {
"vagrant_consul_nomad_ips" => $all_nodes,
"vagrant_loadbalancer_ip" => "#{get_ip(0)}"
}
}
end
end