github.com/dkerwin/nomad@v0.3.3-0.20160525181927-74554135514b/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 GO_VERSION="1.6.2" 9 CONSUL_VERSION="0.6.4" 10 11 # Install Prereq Packages 12 sudo apt-get update 13 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 14 15 # Setup go, for development of Nomad 16 SRCROOT="/opt/go" 17 SRCPATH="/opt/gopath" 18 19 # Get the ARCH 20 ARCH=`uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|'` 21 22 # Install Go 23 cd /tmp 24 wget -q https://storage.googleapis.com/golang/go${GO_VERSION}.linux-${ARCH}.tar.gz 25 tar -xf go${GO_VERSION}.linux-${ARCH}.tar.gz 26 sudo mv go $SRCROOT 27 sudo chmod 775 $SRCROOT 28 sudo chown vagrant:vagrant $SRCROOT 29 30 # Setup the GOPATH; even though the shared folder spec gives the working 31 # directory the right user/group, we need to set it properly on the 32 # parent path to allow subsequent "go get" commands to work. 33 sudo mkdir -p $SRCPATH 34 sudo chown -R vagrant:vagrant $SRCPATH 2>/dev/null || true 35 # ^^ silencing errors here because we expect this to fail for the shared folder 36 37 cat <<EOF >/tmp/gopath.sh 38 export GOPATH="$SRCPATH" 39 export GOROOT="$SRCROOT" 40 export PATH="$SRCROOT/bin:$SRCPATH/bin:\$PATH" 41 EOF 42 sudo mv /tmp/gopath.sh /etc/profile.d/gopath.sh 43 sudo chmod 0755 /etc/profile.d/gopath.sh 44 source /etc/profile.d/gopath.sh 45 46 echo Fetching Consul... 47 cd /tmp/ 48 wget https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip -O consul.zip 49 echo Installing Consul... 50 unzip consul.zip 51 sudo chmod +x consul 52 sudo mv consul /usr/bin/consul 53 54 # Install Docker 55 echo deb https://apt.dockerproject.org/repo ubuntu-`lsb_release -c | awk '{print $2}'` main | sudo tee /etc/apt/sources.list.d/docker.list 56 sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D 57 sudo apt-get update 58 sudo apt-get install -y docker-engine 59 60 # Restart docker to make sure we get the latest version of the daemon if there is an upgrade 61 sudo service docker restart 62 63 # Make sure we can actually use docker as the vagrant user 64 sudo usermod -aG docker vagrant 65 66 # Setup Nomad for development 67 cd /opt/gopath/src/github.com/hashicorp/nomad && make bootstrap 68 69 # Install rkt 70 bash scripts/install_rkt.sh 71 72 # CD into the nomad working directory when we login to the VM 73 grep "cd /opt/gopath/src/github.com/hashicorp/nomad" ~/.profile || echo "cd /opt/gopath/src/github.com/hashicorp/nomad" >> ~/.profile 74 SCRIPT 75 76 def configureVM(vmCfg) 77 vmCfg.vm.box = "cbednarski/ubuntu-1404" 78 79 vmCfg.vm.provision "shell", inline: $script, privileged: false 80 vmCfg.vm.synced_folder '.', '/opt/gopath/src/github.com/hashicorp/nomad' 81 82 # We're going to compile go and run a concurrent system, so give ourselves 83 # some extra resources. Nomad will have trouble working correctly with <2 84 # CPUs so we should use at least that many. 85 cpus = 2 86 memory = 2048 87 88 vmCfg.vm.provider "parallels" do |p, o| 89 o.vm.box = "parallels/ubuntu-14.04" 90 p.memory = memory 91 p.cpus = cpus 92 end 93 94 vmCfg.vm.provider "virtualbox" do |v| 95 v.memory = memory 96 v.cpus = cpus 97 end 98 99 ["vmware_fusion", "vmware_workstation"].each do |p| 100 vmCfg.vm.provider p do |v| 101 v.gui = false 102 v.memory = memory 103 v.cpus = cpus 104 end 105 end 106 return vmCfg 107 end 108 109 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 110 1.upto(3) do |n| 111 vmName = "nomad-server%02d" % [n] 112 config.vm.define vmName, autostart: (n == 1 ? true : false), primary: (n == 1 ? true : false) do |vmCfg| 113 vmCfg.vm.hostname = vmName 114 vmCfg = configureVM(vmCfg) 115 end 116 end 117 118 1.upto(3) do |n| 119 vmName = "nomad-client%02d" % [n] 120 config.vm.define vmName, autostart: false, primary: false do |vmCfg| 121 vmCfg.vm.hostname = vmName 122 vmCfg = configureVM(vmCfg) 123 end 124 end 125 end