2014-04-10 17:34:10 -07:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
2017-01-13 11:03:10 -05:00
|
|
|
|
2014-04-10 17:34:10 -07:00
|
|
|
$script = <<SCRIPT
|
|
|
|
|
2017-01-13 11:03:10 -05:00
|
|
|
echo "Installing dependencies ..."
|
2015-11-28 22:52:40 +07:00
|
|
|
sudo apt-get update
|
2018-04-13 18:01:42 +01:00
|
|
|
sudo apt-get install -y unzip curl jq dnsutils
|
2017-03-01 13:19:59 -05:00
|
|
|
|
|
|
|
echo "Determining Consul version to install ..."
|
|
|
|
CHECKPOINT_URL="https://checkpoint-api.hashicorp.com/v1/check"
|
|
|
|
if [ -z "$CONSUL_DEMO_VERSION" ]; then
|
|
|
|
CONSUL_DEMO_VERSION=$(curl -s "${CHECKPOINT_URL}"/consul | jq .current_version | tr -d '"')
|
|
|
|
fi
|
2014-04-10 17:34:10 -07:00
|
|
|
|
2017-01-13 11:03:10 -05:00
|
|
|
echo "Fetching Consul version ${CONSUL_DEMO_VERSION} ..."
|
2014-04-10 17:34:10 -07:00
|
|
|
cd /tmp/
|
2017-01-13 11:03:10 -05:00
|
|
|
curl -s https://releases.hashicorp.com/consul/${CONSUL_DEMO_VERSION}/consul_${CONSUL_DEMO_VERSION}_linux_amd64.zip -o consul.zip
|
2014-04-10 17:34:10 -07:00
|
|
|
|
2017-01-13 11:03:10 -05:00
|
|
|
echo "Installing Consul version ${CONSUL_DEMO_VERSION} ..."
|
2014-04-10 17:34:10 -07:00
|
|
|
unzip consul.zip
|
|
|
|
sudo chmod +x consul
|
|
|
|
sudo mv consul /usr/bin/consul
|
|
|
|
|
2015-07-22 13:33:15 +02:00
|
|
|
sudo mkdir /etc/consul.d
|
|
|
|
sudo chmod a+w /etc/consul.d
|
|
|
|
|
2014-04-10 17:34:10 -07:00
|
|
|
SCRIPT
|
|
|
|
|
2017-01-13 11:03:10 -05:00
|
|
|
# Specify a Consul version
|
2017-03-01 13:19:59 -05:00
|
|
|
CONSUL_DEMO_VERSION = ENV['CONSUL_DEMO_VERSION']
|
2017-01-13 11:03:10 -05:00
|
|
|
|
2016-11-21 12:49:59 -05:00
|
|
|
# Specify a custom Vagrant box for the demo
|
2018-02-13 20:01:36 +01:00
|
|
|
DEMO_BOX_NAME = ENV['DEMO_BOX_NAME'] || "debian/stretch64"
|
2016-11-21 12:49:59 -05:00
|
|
|
|
|
|
|
# Vagrantfile API/syntax version.
|
|
|
|
# NB: Don't touch unless you know what you're doing!
|
2014-04-10 17:34:10 -07:00
|
|
|
VAGRANTFILE_API_VERSION = "2"
|
|
|
|
|
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
2016-11-21 12:49:59 -05:00
|
|
|
config.vm.box = DEMO_BOX_NAME
|
2014-04-10 17:34:10 -07:00
|
|
|
|
2017-01-13 11:03:10 -05:00
|
|
|
config.vm.provision "shell",
|
|
|
|
inline: $script,
|
|
|
|
env: {'CONSUL_DEMO_VERSION' => CONSUL_DEMO_VERSION}
|
2014-04-10 17:34:10 -07:00
|
|
|
|
|
|
|
config.vm.define "n1" do |n1|
|
2014-04-20 14:04:43 +02:00
|
|
|
n1.vm.hostname = "n1"
|
2014-04-10 17:34:10 -07:00
|
|
|
n1.vm.network "private_network", ip: "172.20.20.10"
|
|
|
|
end
|
|
|
|
|
|
|
|
config.vm.define "n2" do |n2|
|
2014-04-20 14:04:43 +02:00
|
|
|
n2.vm.hostname = "n2"
|
2014-04-10 17:34:10 -07:00
|
|
|
n2.vm.network "private_network", ip: "172.20.20.11"
|
|
|
|
end
|
|
|
|
end
|