github.com/huiliang/nomad@v0.2.1-0.20151124023127-7a8b664699ff/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
    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.1.linux-${ARCH}.tar.gz
    22  tar -xf go1.5.1.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  # Install Docker
    44  echo deb https://apt.dockerproject.org/repo ubuntu-`lsb_release -c | awk '{print $2}'` main | sudo tee /etc/apt/sources.list.d/docker.list
    45  sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
    46  sudo apt-get update
    47  sudo apt-get install -y docker-engine
    48  
    49  # Restart docker to make sure we get the latest version of the daemon if there is an upgrade
    50  sudo service docker restart
    51  
    52  # Make sure we can actually use docker as the vagrant user
    53  sudo usermod -aG docker vagrant
    54  
    55  # Setup Nomad for development
    56  cd /opt/gopath/src/github.com/hashicorp/nomad && make updatedeps
    57  
    58  # CD into the nomad working directory when we login to the VM
    59  grep "cd /opt/gopath/src/github.com/hashicorp/nomad" ~/.profile || echo "cd /opt/gopath/src/github.com/hashicorp/nomad" >> ~/.profile
    60  SCRIPT
    61  
    62  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    63    config.vm.box = "cbednarski/ubuntu-1404"
    64    config.vm.hostname = "nomad"
    65  
    66    config.vm.provision "shell", inline: $script, privileged: false
    67    config.vm.synced_folder '.', '/opt/gopath/src/github.com/hashicorp/nomad'
    68  
    69    # We're going to compile go and run a concurrent system, so give ourselves
    70    # some extra resources. Nomad will have trouble working correctly with <2 CPUs
    71    # so we should use at least that many.
    72    cpus = 2
    73    memory = 2048
    74  
    75    config.vm.provider "parallels" do |p, o|
    76      o.vm.box = "parallels/ubuntu-14.04"
    77      p.memory = memory
    78      p.cpus = cpus
    79    end
    80  
    81    config.vm.provider "virtualbox" do |v|
    82      v.memory = memory
    83      v.cpus = cpus
    84    end
    85  
    86    ["vmware_fusion", "vmware_workstation"].each do |p|
    87      config.vm.provider p do |v|
    88        v.memory = memory
    89        v.cpus = cpus
    90      end
    91    end
    92  end