2015-09-23 05:48:39 +00:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
$script = <<SCRIPT
|
2018-12-01 22:03:44 +00:00
|
|
|
echo "Installing Docker..."
|
|
|
|
sudo apt-get update
|
|
|
|
sudo apt-get remove docker docker-engine docker.io
|
2019-11-24 00:35:09 +00:00
|
|
|
echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections
|
2018-12-01 22:03:44 +00:00
|
|
|
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
|
|
|
|
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
|
|
|
|
sudo apt-key fingerprint 0EBFCD88
|
|
|
|
sudo add-apt-repository \
|
|
|
|
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
|
|
|
$(lsb_release -cs) \
|
|
|
|
stable"
|
2015-09-23 05:48:39 +00:00
|
|
|
sudo apt-get update
|
2018-12-01 22:03:44 +00:00
|
|
|
sudo apt-get install -y docker-ce
|
|
|
|
# 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
|
|
|
|
sudo docker --version
|
2015-09-23 05:48:39 +00:00
|
|
|
|
2018-12-01 22:03:44 +00:00
|
|
|
# Packages required for nomad & consul
|
|
|
|
sudo apt-get install unzip curl vim -y
|
2017-07-11 15:00:46 +00:00
|
|
|
|
2018-12-01 22:03:44 +00:00
|
|
|
echo "Installing Nomad..."
|
2020-07-24 15:52:58 +00:00
|
|
|
NOMAD_VERSION=0.12.1
|
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-29 22:40:12 +00:00
|
|
|
unzip nomad.zip
|
2017-07-11 15:00:46 +00:00
|
|
|
sudo install nomad /usr/bin/nomad
|
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
|
|
|
|
|
2017-06-20 20:21:55 +00:00
|
|
|
|
|
|
|
echo "Installing Consul..."
|
2020-04-15 14:57:33 +00:00
|
|
|
CONSUL_VERSION=1.7.2
|
2018-12-01 22:03:44 +00:00
|
|
|
curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip
|
2017-07-11 15:00:46 +00:00
|
|
|
unzip /tmp/consul.zip
|
|
|
|
sudo install consul /usr/bin/consul
|
|
|
|
(
|
|
|
|
cat <<-EOF
|
2018-12-01 22:03:44 +00:00
|
|
|
[Unit]
|
|
|
|
Description=consul agent
|
|
|
|
Requires=network-online.target
|
2019-03-26 22:23:38 +00:00
|
|
|
After=network-online.target
|
2018-12-01 22:03:44 +00:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
Restart=on-failure
|
|
|
|
ExecStart=/usr/bin/consul agent -dev
|
|
|
|
ExecReload=/bin/kill -HUP $MAINPID
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
2017-07-11 15:00:46 +00:00
|
|
|
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
|
2018-12-01 22:03:44 +00:00
|
|
|
echo "Installing $bin..."
|
|
|
|
curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
|
|
|
|
sudo install /tmp/${bin} /usr/local/bin/${bin}
|
2017-07-27 21:47:43 +00:00
|
|
|
done
|
2017-08-25 23:38:24 +00:00
|
|
|
nomad -autocomplete-install
|
|
|
|
|
2015-09-23 05:48:39 +00:00
|
|
|
SCRIPT
|
|
|
|
|
|
|
|
Vagrant.configure(2) do |config|
|
2019-10-09 16:30:23 +00:00
|
|
|
config.vm.box = "bento/ubuntu-18.04" # 18.04 LTS
|
2015-09-23 05:48:39 +00:00
|
|
|
config.vm.hostname = "nomad"
|
|
|
|
config.vm.provision "shell", inline: $script, privileged: false
|
2018-12-01 22:03:44 +00:00
|
|
|
|
2017-11-01 18:15:44 +00:00
|
|
|
# Expose the nomad api and ui to the host
|
2020-02-15 21:06:53 +00:00
|
|
|
config.vm.network "forwarded_port", guest: 4646, host: 4646, auto_correct: true, host_ip: "127.0.0.1"
|
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
|