76 lines
2.2 KiB
Ruby
76 lines
2.2 KiB
Ruby
# -*- mode: ruby -*-
|
|
# vi: set ft=ruby :
|
|
|
|
$script = <<SCRIPT
|
|
# Update apt and get dependencies
|
|
sudo apt-get update
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y unzip curl wget vim
|
|
|
|
# Download Nomad
|
|
NOMAD_VERSION=0.5.6
|
|
echo Fetching Nomad...
|
|
cd /tmp/
|
|
curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
|
|
|
|
echo "Installing Nomad..."
|
|
unzip nomad.zip
|
|
sudo chmod +x nomad
|
|
sudo mv nomad /usr/bin/nomad
|
|
|
|
sudo mkdir -p /etc/nomad.d
|
|
sudo chmod a+w /etc/nomad.d
|
|
|
|
# Set hostname's IP to made advertisement Just Work
|
|
#sudo sed -i -e "s/.*nomad.*/$(ip route get 1 | awk '{print $NF;exit}') nomad/" /etc/hosts
|
|
|
|
echo "Install Docker..."
|
|
if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
|
|
echo "Docker repository already installed; Skipping"
|
|
else
|
|
echo deb https://apt.dockerproject.org/repo ubuntu-`lsb_release -c | awk '{print $2}'` main | sudo tee /etc/apt/sources.list.d/docker.list
|
|
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
|
|
sudo apt-get update
|
|
fi
|
|
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-engine
|
|
|
|
# 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..."
|
|
cd /opt/nomad
|
|
bash scripts/install_consul.sh
|
|
sudo install -o root /opt/nomad/demo/vagrant/consul.service /etc/systemd/system/consul.service
|
|
sudo systemctl enable consul.service
|
|
sudo systemctl start consul
|
|
|
|
SCRIPT
|
|
|
|
Vagrant.configure(2) do |config|
|
|
config.vm.box = "bento/ubuntu-16.04" # 16.04 LTS
|
|
config.vm.hostname = "nomad"
|
|
config.vm.provision "shell", inline: $script, privileged: false
|
|
config.vm.provision "docker" # Just install it
|
|
|
|
config.vm.synced_folder '../..', '/opt/nomad'
|
|
|
|
# Increase memory for Parallels Desktop
|
|
config.vm.provider "parallels" do |p, o|
|
|
p.memory = "1024"
|
|
end
|
|
|
|
# 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
|