2015-09-23 05:48:39 +00:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
$script = <<SCRIPT
|
|
|
|
# Update apt and get dependencies
|
|
|
|
sudo apt-get update
|
2017-07-11 15:00:46 +00:00
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y unzip curl vim \
|
|
|
|
apt-transport-https \
|
|
|
|
ca-certificates \
|
2017-07-27 21:47:43 +00:00
|
|
|
software-properties-common
|
2015-09-23 05:48:39 +00:00
|
|
|
|
|
|
|
# Download Nomad
|
2017-09-11 23:46:54 +00:00
|
|
|
NOMAD_VERSION=0.6.3
|
2017-07-11 15:00:46 +00:00
|
|
|
|
|
|
|
echo "Fetching Nomad..."
|
2015-09-23 05:48:39 +00:00
|
|
|
cd /tmp/
|
2017-04-25 21:02:33 +00:00
|
|
|
curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
|
2015-09-23 05:48:39 +00:00
|
|
|
|
2017-07-11 15:00:46 +00:00
|
|
|
echo "Fetching Consul..."
|
2017-09-24 03:38:32 +00:00
|
|
|
curl -sSL https://releases.hashicorp.com/consul/0.9.3/consul_0.9.3_linux_amd64.zip > consul.zip
|
2017-07-11 15:00:46 +00:00
|
|
|
|
2017-06-20 20:21:55 +00:00
|
|
|
echo "Installing Nomad..."
|
2015-09-29 22:40:12 +00:00
|
|
|
unzip nomad.zip
|
2017-07-11 15:00:46 +00:00
|
|
|
sudo install nomad /usr/bin/nomad
|
2015-09-23 05:48:39 +00:00
|
|
|
|
2015-11-30 14:59:30 +00:00
|
|
|
sudo mkdir -p /etc/nomad.d
|
2015-09-23 05:48:39 +00:00
|
|
|
sudo chmod a+w /etc/nomad.d
|
|
|
|
|
2016-12-16 00:07:28 +00:00
|
|
|
# Set hostname's IP to made advertisement Just Work
|
2017-06-20 20:21:55 +00:00
|
|
|
#sudo sed -i -e "s/.*nomad.*/$(ip route get 1 | awk '{print $NF;exit}') nomad/" /etc/hosts
|
|
|
|
|
2017-07-11 15:00:46 +00:00
|
|
|
echo "Installing Docker..."
|
2017-06-20 20:21:55 +00:00
|
|
|
if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
|
|
|
|
echo "Docker repository already installed; Skipping"
|
|
|
|
else
|
2017-07-11 15:00:46 +00:00
|
|
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
|
|
|
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
|
2017-06-20 20:21:55 +00:00
|
|
|
sudo apt-get update
|
|
|
|
fi
|
2017-07-11 15:00:46 +00:00
|
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce
|
2017-06-20 20:21:55 +00:00
|
|
|
|
|
|
|
# Restart docker to make sure we get the latest version of the daemon if there is an upgrade
|
|
|
|
sudo service docker restart
|
|
|
|
|
|
|
|
# Make sure we can actually use docker as the vagrant user
|
|
|
|
sudo usermod -aG docker vagrant
|
|
|
|
|
|
|
|
echo "Installing Consul..."
|
2017-07-11 15:00:46 +00:00
|
|
|
unzip /tmp/consul.zip
|
|
|
|
sudo install consul /usr/bin/consul
|
|
|
|
(
|
|
|
|
cat <<-EOF
|
|
|
|
[Unit]
|
|
|
|
Description=consul agent
|
|
|
|
Requires=network-online.target
|
|
|
|
After=network-online.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Restart=on-failure
|
|
|
|
ExecStart=/usr/bin/consul agent -dev
|
|
|
|
ExecReload=/bin/kill -HUP $MAINPID
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
) | sudo tee /etc/systemd/system/consul.service
|
2017-07-03 23:43:47 +00:00
|
|
|
sudo systemctl enable consul.service
|
|
|
|
sudo systemctl start consul
|
2016-12-16 00:07:28 +00:00
|
|
|
|
2017-07-27 21:47:43 +00:00
|
|
|
for bin in cfssl cfssl-certinfo cfssljson
|
|
|
|
do
|
|
|
|
echo "Installing $bin..."
|
|
|
|
curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
|
|
|
|
sudo install /tmp/${bin} /usr/local/bin/${bin}
|
|
|
|
done
|
|
|
|
|
2017-08-25 23:38:24 +00:00
|
|
|
echo "Installing autocomplete..."
|
|
|
|
nomad -autocomplete-install
|
|
|
|
|
2015-09-23 05:48:39 +00:00
|
|
|
SCRIPT
|
|
|
|
|
|
|
|
Vagrant.configure(2) do |config|
|
2017-06-20 20:21:55 +00:00
|
|
|
config.vm.box = "bento/ubuntu-16.04" # 16.04 LTS
|
2015-09-23 05:48:39 +00:00
|
|
|
config.vm.hostname = "nomad"
|
|
|
|
config.vm.provision "shell", inline: $script, privileged: false
|
2015-10-02 05:24:17 +00:00
|
|
|
config.vm.provision "docker" # Just install it
|
2015-09-23 05:48:39 +00:00
|
|
|
|
2015-10-02 17:43:30 +00:00
|
|
|
# Increase memory for Parallels Desktop
|
|
|
|
config.vm.provider "parallels" do |p, o|
|
|
|
|
p.memory = "1024"
|
|
|
|
end
|
|
|
|
|
2015-09-23 05:48:39 +00:00
|
|
|
# Increase memory for Virtualbox
|
|
|
|
config.vm.provider "virtualbox" do |vb|
|
|
|
|
vb.memory = "1024"
|
|
|
|
end
|
|
|
|
|
|
|
|
# Increase memory for VMware
|
|
|
|
["vmware_fusion", "vmware_workstation"].each do |p|
|
|
|
|
config.vm.provider p do |v|
|
|
|
|
v.vmx["memsize"] = "1024"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|