github.com/hhrutter/nomad@v0.6.0-rc2.0.20170723054333-80c4b03f0705/demo/vagrant/Vagrantfile (about)

     1  # -*- mode: ruby -*-
     2  # vi: set ft=ruby :
     3  
     4  $script = <<SCRIPT
     5  # Update apt and get dependencies
     6  sudo apt-get update
     7  sudo DEBIAN_FRONTEND=noninteractive apt-get install -y unzip curl vim \
     8      apt-transport-https \
     9      ca-certificates \
    10      software-properties-common
    11  
    12  # Download Nomad
    13  NOMAD_VERSION=0.5.6
    14  
    15  echo "Fetching Nomad..."
    16  cd /tmp/
    17  curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
    18  
    19  echo "Fetching Consul..."
    20  curl -sSL https://releases.hashicorp.com/consul/0.8.5/consul_0.8.5_linux_amd64.zip > consul.zip
    21  
    22  echo "Installing Nomad..."
    23  unzip nomad.zip
    24  sudo install nomad /usr/bin/nomad
    25  
    26  sudo mkdir -p /etc/nomad.d
    27  sudo chmod a+w /etc/nomad.d
    28  
    29  # Set hostname's IP to made advertisement Just Work
    30  #sudo sed -i -e "s/.*nomad.*/$(ip route get 1 | awk '{print $NF;exit}') nomad/" /etc/hosts
    31  
    32  echo "Installing Docker..."
    33  if [[ -f /etc/apt/sources.list.d/docker.list ]]; then
    34      echo "Docker repository already installed; Skipping"
    35  else
    36      curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    37      sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    38      sudo apt-get update
    39  fi
    40  sudo DEBIAN_FRONTEND=noninteractive apt-get install -y docker-ce
    41  
    42  # Restart docker to make sure we get the latest version of the daemon if there is an upgrade
    43  sudo service docker restart
    44  
    45  # Make sure we can actually use docker as the vagrant user
    46  sudo usermod -aG docker vagrant
    47  
    48  echo "Installing Consul..."
    49  unzip /tmp/consul.zip
    50  sudo install consul /usr/bin/consul
    51  (
    52  cat <<-EOF
    53  	[Unit]
    54  	Description=consul agent
    55  	Requires=network-online.target
    56  	After=network-online.target
    57  	
    58  	[Service]
    59  	Restart=on-failure
    60  	ExecStart=/usr/bin/consul agent -dev
    61  	ExecReload=/bin/kill -HUP $MAINPID
    62  	
    63  	[Install]
    64  	WantedBy=multi-user.target
    65  EOF
    66  ) | sudo tee /etc/systemd/system/consul.service
    67  sudo systemctl enable consul.service
    68  sudo systemctl start consul
    69  
    70  SCRIPT
    71  
    72  Vagrant.configure(2) do |config|
    73    config.vm.box = "bento/ubuntu-16.04" # 16.04 LTS
    74    config.vm.hostname = "nomad"
    75    config.vm.provision "shell", inline: $script, privileged: false
    76    config.vm.provision "docker" # Just install it
    77  
    78    # Increase memory for Parallels Desktop
    79    config.vm.provider "parallels" do |p, o|
    80      p.memory = "1024"
    81    end
    82  
    83    # Increase memory for Virtualbox
    84    config.vm.provider "virtualbox" do |vb|
    85          vb.memory = "1024"
    86    end
    87  
    88    # Increase memory for VMware
    89    ["vmware_fusion", "vmware_workstation"].each do |p|
    90      config.vm.provider p do |v|
    91        v.vmx["memsize"] = "1024"
    92      end
    93    end
    94  end