github.com/recobe182/terraform@v0.8.5-0.20170117231232-49ab22a935b7/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 # Software version variables 8 GOVERSION = "1.7.4" 9 UBUNTUVERSION = "16.04" 10 11 # CPU and RAM can be adjusted depending on your system 12 CPUCOUNT = "2" 13 RAM = "4096" 14 15 $script = <<SCRIPT 16 GOVERSION="#{GOVERSION}" 17 SRCROOT="/opt/go" 18 SRCPATH="/opt/gopath" 19 20 # Get the ARCH 21 ARCH="$(uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|')" 22 23 # Install Prereq Packages 24 export DEBIAN_PRIORITY=critical 25 export DEBIAN_FRONTEND=noninteractive 26 export DEBCONF_NONINTERACTIVE_SEEN=true 27 APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" 28 echo "Upgrading packages ..." 29 apt-get update ${APT_OPTS} >/dev/null 30 apt-get upgrade ${APT_OPTS} >/dev/null 31 echo "Installing prerequisites ..." 32 apt-get install ${APT_OPTS} build-essential curl git-core libpcre3-dev mercurial pkg-config zip >/dev/null 33 34 # Install Go 35 echo "Downloading go (${GOVERSION}) ..." 36 wget -P /tmp --quiet "https://storage.googleapis.com/golang/go${GOVERSION}.linux-${ARCH}.tar.gz" 37 echo "Setting up go (${GOVERSION}) ..." 38 tar -C /opt -xf "/tmp/go${GOVERSION}.linux-${ARCH}.tar.gz" 39 chmod 775 "$SRCROOT" 40 chown vagrant:vagrant "$SRCROOT" 41 42 # Setup the GOPATH; even though the shared folder spec gives the working 43 # directory the right user/group, we need to set it properly on the 44 # parent path to allow subsequent "go get" commands to work. 45 mkdir -p "$SRCPATH" 46 chown -R vagrant:vagrant "$SRCPATH" 2>/dev/null || true 47 # ^^ silencing errors here because we expect this to fail for the shared folder 48 49 cat >/etc/profile.d/gopath.sh <<EOF 50 export GOPATH="$SRCPATH" 51 export GOROOT="$SRCROOT" 52 export PATH="$SRCROOT/bin:$SRCPATH/bin:\$PATH" 53 EOF 54 chmod 755 /etc/profile.d/gopath.sh 55 56 grep -q -F 'cd /opt/gopath/src/github.com/hashicorp/terraform' /home/vagrant/.bashrc || cat >>/home/vagrant/.bashrc <<EOF 57 58 ## After login, change to terraform directory 59 cd /opt/gopath/src/github.com/hashicorp/terraform 60 EOF 61 62 SCRIPT 63 64 Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 65 config.vm.box = "bento/ubuntu-#{UBUNTUVERSION}" 66 config.vm.hostname = "terraform" 67 68 config.vm.provision "prepare-shell", type: "shell", inline: "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile", privileged: false 69 config.vm.provision "initial-setup", type: "shell", inline: $script 70 config.vm.synced_folder '.', '/opt/gopath/src/github.com/hashicorp/terraform' 71 72 config.vm.provider "docker" do |v, override| 73 override.vm.box = "tknerr/baseimage-ubuntu-#{UBUNTUVERSION}" 74 end 75 76 ["vmware_fusion", "vmware_workstation"].each do |p| 77 config.vm.provider p do |v| 78 v.vmx["memsize"] = "#{RAM}" 79 v.vmx["numvcpus"] = "#{CPUCOUNT}" 80 end 81 end 82 83 config.vm.provider "virtualbox" do |v| 84 v.memory = "#{RAM}" 85 v.cpus = "#{CPUCOUNT}" 86 end 87 88 config.vm.provider "parallels" do |prl| 89 prl.memory = "#{RAM}" 90 prl.cpus = "#{CPUCOUNT}" 91 end 92 end