2015-07-01 10:20:00 -04:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
|
|
|
VAGRANTFILE_API_VERSION = "2"
|
|
|
|
|
|
|
|
$consul=<<SCRIPT
|
|
|
|
apt-get update
|
|
|
|
apt-get -y install wget
|
|
|
|
wget -qO- https://experimental.docker.com/ | sh
|
|
|
|
gpasswd -a vagrant docker
|
|
|
|
service docker restart
|
|
|
|
docker run -d -p 8500:8500 -p 8300-8302:8300-8302/tcp -p 8300-8302:8300-8302/udp -h consul progrium/consul -server -bootstrap
|
|
|
|
SCRIPT
|
|
|
|
|
|
|
|
$bootstrap=<<SCRIPT
|
|
|
|
apt-get update
|
|
|
|
apt-get -y install wget curl
|
|
|
|
apt-get -y install bridge-utils
|
|
|
|
wget -qO- https://experimental.docker.com/ | sh
|
|
|
|
gpasswd -a vagrant docker
|
2015-10-12 16:54:58 -04:00
|
|
|
echo DOCKER_OPTS=\\"--cluster-store=consul://192.168.33.10:8500 --cluster-advertise=${1}:0\\" >> /etc/default/docker
|
2015-07-31 21:08:27 -04:00
|
|
|
cp /vagrant/vagrant-systemd/docker.service /etc/systemd/system/
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl restart docker.service
|
2015-07-01 10:20:00 -04:00
|
|
|
SCRIPT
|
|
|
|
|
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
|
|
|
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
|
|
|
|
num_nodes = 2
|
|
|
|
base_ip = "192.168.33."
|
|
|
|
net_ips = num_nodes.times.collect { |n| base_ip + "#{n+11}" }
|
|
|
|
|
|
|
|
config.vm.define "consul-server" do |consul|
|
|
|
|
consul.vm.box = "ubuntu/trusty64"
|
|
|
|
consul.vm.hostname = "consul-server"
|
|
|
|
consul.vm.network :private_network, ip: "192.168.33.10"
|
|
|
|
consul.vm.provider "virtualbox" do |vb|
|
|
|
|
vb.customize ["modifyvm", :id, "--memory", "512"]
|
|
|
|
end
|
|
|
|
consul.vm.provision :shell, inline: $consul
|
|
|
|
end
|
|
|
|
|
|
|
|
num_nodes.times do |n|
|
|
|
|
config.vm.define "net-#{n+1}" do |net|
|
2015-07-31 21:08:27 -04:00
|
|
|
net.vm.box = "ubuntu/vivid64"
|
2015-07-01 10:20:00 -04:00
|
|
|
net_ip = net_ips[n]
|
|
|
|
net_index = n+1
|
|
|
|
net.vm.hostname = "net-#{net_index}"
|
|
|
|
net.vm.provider "virtualbox" do |vb|
|
|
|
|
vb.customize ["modifyvm", :id, "--memory", "1024"]
|
|
|
|
end
|
|
|
|
net.vm.network :private_network, ip: "#{net_ip}"
|
2015-10-12 16:54:58 -04:00
|
|
|
net.vm.provision :shell, inline: $bootstrap, :args => "#{net_ip}"
|
2015-07-01 10:20:00 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|