github.com/ferranbt/nomad@v0.9.3-0.20190607002617-85c449b7667c/demo/vagrant/Vagrantfile (about)

     1  # -*- mode: ruby -*-
     2  # vi: set ft=ruby :
     3  
     4  $script = <<SCRIPT
     5  echo "Installing Docker..."
     6  sudo apt-get update
     7  sudo apt-get remove docker docker-engine docker.io
     8  sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
     9  sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg |  sudo apt-key add -
    10  sudo apt-key fingerprint 0EBFCD88
    11  sudo add-apt-repository \
    12        "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    13        $(lsb_release -cs) \
    14        stable"
    15  sudo apt-get update
    16  sudo apt-get install -y docker-ce
    17  # Restart docker to make sure we get the latest version of the daemon if there is an upgrade
    18  sudo service docker restart
    19  # Make sure we can actually use docker as the vagrant user
    20  sudo usermod -aG docker vagrant
    21  sudo docker --version
    22  
    23  # Packages required for nomad & consul
    24  sudo apt-get install unzip curl vim -y
    25  
    26  echo "Installing Nomad..."
    27  NOMAD_VERSION=0.8.6
    28  cd /tmp/
    29  curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
    30  unzip nomad.zip
    31  sudo install nomad /usr/bin/nomad
    32  sudo mkdir -p /etc/nomad.d
    33  sudo chmod a+w /etc/nomad.d
    34  
    35  
    36  echo "Installing Consul..."
    37  CONSUL_VERSION=1.4.0
    38  curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip
    39  unzip /tmp/consul.zip
    40  sudo install consul /usr/bin/consul
    41  (
    42  cat <<-EOF
    43    [Unit]
    44    Description=consul agent
    45    Requires=network-online.target
    46    After=network-online.target
    47  
    48    [Service]
    49    Restart=on-failure
    50    ExecStart=/usr/bin/consul agent -dev
    51    ExecReload=/bin/kill -HUP $MAINPID
    52  
    53    [Install]
    54    WantedBy=multi-user.target
    55  EOF
    56  ) | sudo tee /etc/systemd/system/consul.service
    57  sudo systemctl enable consul.service
    58  sudo systemctl start consul
    59  
    60  for bin in cfssl cfssl-certinfo cfssljson
    61  do
    62    echo "Installing $bin..."
    63    curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
    64    sudo install /tmp/${bin} /usr/local/bin/${bin}
    65  done
    66  nomad -autocomplete-install
    67  
    68  SCRIPT
    69  
    70  Vagrant.configure(2) do |config|
    71    config.vm.box = "bento/ubuntu-16.04" # 16.04 LTS
    72    config.vm.hostname = "nomad"
    73    config.vm.provision "shell", inline: $script, privileged: false
    74  
    75    # Expose the nomad api and ui to the host
    76    config.vm.network "forwarded_port", guest: 4646, host: 4646, auto_correct: true
    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