github.com/superfly/nomad@v0.10.5-fly/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  echo '* libraries/restart-without-asking boolean true' | sudo debconf-set-selections
     9  sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
    10  sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg |  sudo apt-key add -
    11  sudo apt-key fingerprint 0EBFCD88
    12  sudo add-apt-repository \
    13        "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
    14        $(lsb_release -cs) \
    15        stable"
    16  sudo apt-get update
    17  sudo apt-get install -y docker-ce
    18  # Restart docker to make sure we get the latest version of the daemon if there is an upgrade
    19  sudo service docker restart
    20  # Make sure we can actually use docker as the vagrant user
    21  sudo usermod -aG docker vagrant
    22  sudo docker --version
    23  
    24  # Packages required for nomad & consul
    25  sudo apt-get install unzip curl vim -y
    26  
    27  echo "Installing Nomad..."
    28  NOMAD_VERSION=0.10.3
    29  cd /tmp/
    30  curl -sSL https://releases.hashicorp.com/nomad/${NOMAD_VERSION}/nomad_${NOMAD_VERSION}_linux_amd64.zip -o nomad.zip
    31  unzip nomad.zip
    32  sudo install nomad /usr/bin/nomad
    33  sudo mkdir -p /etc/nomad.d
    34  sudo chmod a+w /etc/nomad.d
    35  
    36  
    37  echo "Installing Consul..."
    38  CONSUL_VERSION=1.6.1
    39  curl -sSL https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip > consul.zip
    40  unzip /tmp/consul.zip
    41  sudo install consul /usr/bin/consul
    42  (
    43  cat <<-EOF
    44    [Unit]
    45    Description=consul agent
    46    Requires=network-online.target
    47    After=network-online.target
    48  
    49    [Service]
    50    Restart=on-failure
    51    ExecStart=/usr/bin/consul agent -dev
    52    ExecReload=/bin/kill -HUP $MAINPID
    53  
    54    [Install]
    55    WantedBy=multi-user.target
    56  EOF
    57  ) | sudo tee /etc/systemd/system/consul.service
    58  sudo systemctl enable consul.service
    59  sudo systemctl start consul
    60  
    61  for bin in cfssl cfssl-certinfo cfssljson
    62  do
    63    echo "Installing $bin..."
    64    curl -sSL https://pkg.cfssl.org/R1.2/${bin}_linux-amd64 > /tmp/${bin}
    65    sudo install /tmp/${bin} /usr/local/bin/${bin}
    66  done
    67  nomad -autocomplete-install
    68  
    69  SCRIPT
    70  
    71  Vagrant.configure(2) do |config|
    72    config.vm.box = "bento/ubuntu-18.04" # 18.04 LTS
    73    config.vm.hostname = "nomad"
    74    config.vm.provision "shell", inline: $script, privileged: false
    75  
    76    # Expose the nomad api and ui to the host
    77    config.vm.network "forwarded_port", guest: 4646, host: 4646, auto_correct: true
    78  
    79    # Increase memory for Parallels Desktop
    80    config.vm.provider "parallels" do |p, o|
    81      p.memory = "1024"
    82    end
    83  
    84    # Increase memory for Virtualbox
    85    config.vm.provider "virtualbox" do |vb|
    86          vb.memory = "1024"
    87    end
    88  
    89    # Increase memory for VMware
    90    ["vmware_fusion", "vmware_workstation"].each do |p|
    91      config.vm.provider p do |v|
    92        v.vmx["memsize"] = "1024"
    93      end
    94    end
    95  end