github.com/ryanslade/nomad@v0.2.4-0.20160128061903-fc95782f2089/Vagrantfile (about)

     1  # -*- mode: ruby -*-
     2  # vi: set ft=ruby :
     3  
     4  # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
     5  VAGRANTFILE_API_VERSION = "2"
     6  
     7  $script = <<SCRIPT
     8  # Install Prereq Packages
     9  sudo apt-get update
    10  sudo apt-get install -y build-essential curl git-core mercurial bzr libpcre3-dev pkg-config zip default-jre qemu libc6-dev-i386 silversearcher-ag jq htop vim unzip
    11  
    12  # Setup go, for development of Nomad
    13  SRCROOT="/opt/go"
    14  SRCPATH="/opt/gopath"
    15  
    16  # Get the ARCH
    17  ARCH=`uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|'`
    18  
    19  # Install Go
    20  cd /tmp
    21  wget -q https://storage.googleapis.com/golang/go1.5.2.linux-${ARCH}.tar.gz
    22  tar -xf go1.5.2.linux-${ARCH}.tar.gz
    23  sudo mv go $SRCROOT
    24  sudo chmod 775 $SRCROOT
    25  sudo chown vagrant:vagrant $SRCROOT
    26  
    27  # Setup the GOPATH; even though the shared folder spec gives the working
    28  # directory the right user/group, we need to set it properly on the
    29  # parent path to allow subsequent "go get" commands to work.
    30  sudo mkdir -p $SRCPATH
    31  sudo chown -R vagrant:vagrant $SRCPATH 2>/dev/null || true
    32  # ^^ silencing errors here because we expect this to fail for the shared folder
    33  
    34  cat <<EOF >/tmp/gopath.sh
    35  export GOPATH="$SRCPATH"
    36  export GOROOT="$SRCROOT"
    37  export PATH="$SRCROOT/bin:$SRCPATH/bin:\$PATH"
    38  EOF
    39  sudo mv /tmp/gopath.sh /etc/profile.d/gopath.sh
    40  sudo chmod 0755 /etc/profile.d/gopath.sh
    41  source /etc/profile.d/gopath.sh
    42  
    43  echo Fetching Consul...
    44  cd /tmp/
    45  wget https://releases.hashicorp.com/consul/0.6.0/consul_0.6.0_linux_amd64.zip -O consul.zip
    46  echo Installing Consul...
    47  unzip consul.zip
    48  sudo chmod +x consul
    49  sudo mv consul /usr/bin/consul
    50  
    51  # Install Docker
    52  echo deb https://apt.dockerproject.org/repo ubuntu-`lsb_release -c | awk '{print $2}'` main | sudo tee /etc/apt/sources.list.d/docker.list
    53  sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
    54  sudo apt-get update
    55  sudo apt-get install -y docker-engine
    56  
    57  # Restart docker to make sure we get the latest version of the daemon if there is an upgrade
    58  sudo service docker restart
    59  
    60  # Make sure we can actually use docker as the vagrant user
    61  sudo usermod -aG docker vagrant
    62  
    63  # Setup Nomad for development
    64  cd /opt/gopath/src/github.com/hashicorp/nomad && make updatedeps
    65  
    66  # CD into the nomad working directory when we login to the VM
    67  grep "cd /opt/gopath/src/github.com/hashicorp/nomad" ~/.profile || echo "cd /opt/gopath/src/github.com/hashicorp/nomad" >> ~/.profile
    68  SCRIPT
    69  
    70  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    71    config.vm.box = "cbednarski/ubuntu-1404"
    72    config.vm.hostname = "nomad"
    73  
    74    config.vm.provision "shell", inline: $script, privileged: false
    75    config.vm.synced_folder '.', '/opt/gopath/src/github.com/hashicorp/nomad'
    76  
    77    # We're going to compile go and run a concurrent system, so give ourselves
    78    # some extra resources. Nomad will have trouble working correctly with <2 CPUs
    79    # so we should use at least that many.
    80    cpus = 2
    81    memory = 2048
    82  
    83    config.vm.provider "parallels" do |p, o|
    84      o.vm.box = "parallels/ubuntu-14.04"
    85      p.memory = memory
    86      p.cpus = cpus
    87    end
    88  
    89    config.vm.provider "virtualbox" do |v|
    90      v.memory = memory
    91      v.cpus = cpus
    92    end
    93  
    94    ["vmware_fusion", "vmware_workstation"].each do |p|
    95      config.vm.provider p do |v|
    96        v.memory = memory
    97        v.cpus = cpus
    98      end
    99    end
   100  end