-
Notifications
You must be signed in to change notification settings - Fork 2
/
Vagrantfile
75 lines (63 loc) · 1.61 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
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
def create_consul_host(config, hostname, ip, initJson, zService)
config.vm.define hostname do |host|
host.vm.hostname = hostname
host.vm.provision "shell", path: "provision.sh"
host.vm.network "private_network", ip: ip
host.vm.provision "shell", inline: "echo '#{initJson}' > /etc/systemd/system/consul.d/init.json"
host.vm.provision "shell", inline: "echo '#{zService}' > /etc/systemd/system/consul.d/zService.json"
host.vm.provision "shell", inline: "service consul start"
end
end
serverIp = "192.168.99.100"
serverInit = %(
{
"datacenter": "test",
"node_name": "server",
"server": true,
"ui": true,
"advertise_addr": "#{serverIp}",
"client_addr": "#{serverIp}",
"retry_join": ["#{serverIp}"],
"data_dir": "/tmp/consul",
"bootstrap_expect": 1
}
)
zmqService= %(
{
"service": {
"name": "zmq",
"address": "#{serverIp}",
"port": 5555,
"enableTagOverride": false
}
}
)
create_consul_host config, "consul-server", serverIp, serverInit, zmqService
for host_number in 1..5
hostname="host-#{host_number}"
clientIp="192.168.99.10#{host_number}"
clientInit = %(
{
"datacenter": "test",
"node_name": "host-#{host_number}",
"server":false,
"advertise_addr": "#{clientIp}",
"retry_join": ["#{serverIp}"],
"data_dir": "/tmp/consul"
}
)
zmqService= %(
{
"service": {
"name": "zmq",
"address": "#{clientIp}",
"port": 5555,
"enableTagOverride": false
}
}
)
create_consul_host config, hostname, clientIp, clientInit, zmqService
end
end