2014-07-28 00:16:17 +02:00
|
|
|
# -*- mode: ruby -*-
|
|
|
|
# vi: set ft=ruby :
|
|
|
|
|
|
|
|
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
|
|
|
|
VAGRANTFILE_API_VERSION = "2"
|
|
|
|
|
2016-12-12 17:03:35 +01:00
|
|
|
# Software version variables
|
2017-08-02 21:56:35 +02:00
|
|
|
GOVERSION = "1.8.3"
|
2016-12-12 17:03:35 +01:00
|
|
|
UBUNTUVERSION = "16.04"
|
|
|
|
|
|
|
|
# CPU and RAM can be adjusted depending on your system
|
|
|
|
CPUCOUNT = "2"
|
|
|
|
RAM = "4096"
|
|
|
|
|
2014-07-28 00:16:17 +02:00
|
|
|
$script = <<SCRIPT
|
2016-12-12 17:03:35 +01:00
|
|
|
GOVERSION="#{GOVERSION}"
|
2015-05-26 23:12:44 +02:00
|
|
|
SRCROOT="/opt/go"
|
|
|
|
SRCPATH="/opt/gopath"
|
|
|
|
|
|
|
|
# Get the ARCH
|
2016-10-26 16:33:40 +02:00
|
|
|
ARCH="$(uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|')"
|
2015-05-26 23:12:44 +02:00
|
|
|
|
|
|
|
# Install Prereq Packages
|
2016-10-26 16:33:40 +02:00
|
|
|
export DEBIAN_PRIORITY=critical
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
export DEBCONF_NONINTERACTIVE_SEEN=true
|
2016-12-07 12:04:02 +01:00
|
|
|
APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
|
2016-10-26 16:33:40 +02:00
|
|
|
echo "Upgrading packages ..."
|
|
|
|
apt-get update ${APT_OPTS} >/dev/null
|
|
|
|
apt-get upgrade ${APT_OPTS} >/dev/null
|
|
|
|
echo "Installing prerequisites ..."
|
|
|
|
apt-get install ${APT_OPTS} build-essential curl git-core libpcre3-dev mercurial pkg-config zip >/dev/null
|
2014-07-28 00:16:17 +02:00
|
|
|
|
2015-05-26 23:12:44 +02:00
|
|
|
# Install Go
|
2016-10-26 16:33:40 +02:00
|
|
|
echo "Downloading go (${GOVERSION}) ..."
|
|
|
|
wget -P /tmp --quiet "https://storage.googleapis.com/golang/go${GOVERSION}.linux-${ARCH}.tar.gz"
|
|
|
|
echo "Setting up go (${GOVERSION}) ..."
|
|
|
|
tar -C /opt -xf "/tmp/go${GOVERSION}.linux-${ARCH}.tar.gz"
|
|
|
|
chmod 775 "$SRCROOT"
|
|
|
|
chown vagrant:vagrant "$SRCROOT"
|
2015-05-26 23:12:44 +02:00
|
|
|
|
|
|
|
# Setup the GOPATH; even though the shared folder spec gives the working
|
|
|
|
# directory the right user/group, we need to set it properly on the
|
|
|
|
# parent path to allow subsequent "go get" commands to work.
|
2016-10-26 16:33:40 +02:00
|
|
|
mkdir -p "$SRCPATH"
|
|
|
|
chown -R vagrant:vagrant "$SRCPATH" 2>/dev/null || true
|
2015-05-26 23:12:44 +02:00
|
|
|
# ^^ silencing errors here because we expect this to fail for the shared folder
|
|
|
|
|
2017-01-02 18:24:47 +01:00
|
|
|
cat >/etc/profile.d/gopath.sh <<EOF
|
2015-05-26 23:12:44 +02:00
|
|
|
export GOPATH="$SRCPATH"
|
|
|
|
export GOROOT="$SRCROOT"
|
|
|
|
export PATH="$SRCROOT/bin:$SRCPATH/bin:\$PATH"
|
|
|
|
EOF
|
2017-01-02 18:24:47 +01:00
|
|
|
chmod 755 /etc/profile.d/gopath.sh
|
2016-10-26 16:33:40 +02:00
|
|
|
|
2017-01-02 18:26:55 +01:00
|
|
|
grep -q -F 'cd /opt/gopath/src/github.com/hashicorp/terraform' /home/vagrant/.bashrc || cat >>/home/vagrant/.bashrc <<EOF
|
2016-08-17 03:50:14 +02:00
|
|
|
|
|
|
|
## After login, change to terraform directory
|
|
|
|
cd /opt/gopath/src/github.com/hashicorp/terraform
|
|
|
|
EOF
|
2016-10-26 16:33:40 +02:00
|
|
|
|
2014-07-28 00:16:17 +02:00
|
|
|
SCRIPT
|
|
|
|
|
|
|
|
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
|
2016-12-12 17:03:35 +01:00
|
|
|
config.vm.box = "bento/ubuntu-#{UBUNTUVERSION}"
|
2015-07-27 13:36:17 +02:00
|
|
|
config.vm.hostname = "terraform"
|
2014-08-28 18:52:05 +02:00
|
|
|
|
2016-10-26 16:33:40 +02:00
|
|
|
config.vm.provision "prepare-shell", type: "shell", inline: "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile", privileged: false
|
|
|
|
config.vm.provision "initial-setup", type: "shell", inline: $script
|
2015-05-26 23:12:44 +02:00
|
|
|
config.vm.synced_folder '.', '/opt/gopath/src/github.com/hashicorp/terraform'
|
2014-07-28 00:16:17 +02:00
|
|
|
|
2016-10-14 22:23:23 +02:00
|
|
|
config.vm.provider "docker" do |v, override|
|
2016-12-12 17:03:35 +01:00
|
|
|
override.vm.box = "tknerr/baseimage-ubuntu-#{UBUNTUVERSION}"
|
2016-10-14 22:23:23 +02:00
|
|
|
end
|
|
|
|
|
2014-07-28 00:16:17 +02:00
|
|
|
["vmware_fusion", "vmware_workstation"].each do |p|
|
2015-05-26 23:12:44 +02:00
|
|
|
config.vm.provider p do |v|
|
2016-12-12 17:03:35 +01:00
|
|
|
v.vmx["memsize"] = "#{RAM}"
|
|
|
|
v.vmx["numvcpus"] = "#{CPUCOUNT}"
|
2014-07-28 00:16:17 +02:00
|
|
|
end
|
|
|
|
end
|
2015-08-21 19:54:16 +02:00
|
|
|
|
|
|
|
config.vm.provider "virtualbox" do |v|
|
2016-12-12 17:03:35 +01:00
|
|
|
v.memory = "#{RAM}"
|
|
|
|
v.cpus = "#{CPUCOUNT}"
|
2015-08-21 19:54:16 +02:00
|
|
|
end
|
2016-07-15 13:56:48 +02:00
|
|
|
|
|
|
|
config.vm.provider "parallels" do |prl|
|
2016-12-12 17:03:35 +01:00
|
|
|
prl.memory = "#{RAM}"
|
|
|
|
prl.cpus = "#{CPUCOUNT}"
|
2016-07-15 13:56:48 +02:00
|
|
|
end
|
2014-07-28 00:16:17 +02:00
|
|
|
end
|