forked from gliderlabs/docker-consul
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vagrantfile
36 lines (33 loc) · 1.42 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
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Run with: vagrant up --no-parallel
VAGRANTFILE_API_VERSION = '2'
ENV['VAGRANT_DEFAULT_PROVIDER'] = 'docker'
N = 4
DC = "dc"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
(1..N).each do |i|
config.vm.define "n#{i}" do |n|
n.vm.provider "docker" do |d|
d.name = "n#{i}"
d.image = 'progrium/consul'
d.remains_running = true
if i == 1 && N > 1 then # start bootstrap server
d.cmd = ['-dc', DC, '-node', 'n1', '-server', '-bootstrap-expect', "#{N-1}"]
elsif N == 1 then # single node server
d.ports = ['8400:8400', '8500:8500', '8600:53/udp']
d.cmd = ['-dc', DC, '-node', 'n1', '-server', '-bootstrap-expect 1']
elsif i < N then # start servers
d.link('n1:n1')
d.create_args = ['--entrypoint', '/bin/bash']
d.cmd = ['-c', "/bin/start -dc #{DC} -node n#{i} -server -join $N1_PORT_8400_TCP_ADDR"]
else # start client
d.link('n1:n1')
d.ports = ['8400:8400', '8500:8500', '8600:53/udp']
d.create_args = ['--entrypoint', '/bin/bash']
d.cmd = ['-c', "/bin/start -dc #{DC} -node client -join $N1_PORT_8400_TCP_ADDR"]
end
end
end
end
end