-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Krzysztof Wilczynski <krzysztof.wilczynski@linux.com>
- Loading branch information
1 parent
fb08774
commit ca48b1f
Showing
1 changed file
with
70 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,108 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | ||
VAGRANTFILE_API_VERSION = "2" | ||
|
||
$script = <<SCRIPT | ||
GOVERSION="1.7.3" | ||
SRCROOT="/opt/go" | ||
SRCPATH="/opt/gopath" | ||
#!/bin/bash | ||
set -e | ||
set -u | ||
set -o pipefail | ||
GOVERSION='1.7.3' | ||
SRCROOT='/opt/go' | ||
SRCPATH='/opt/gopath' | ||
umask 022 | ||
# Get the ARCH | ||
ARCH="$(uname -m | sed 's|i686|386|' | sed 's|x86_64|amd64|')" | ||
ARCH=$(uname -m | sed 's/i686/386/;s/x86_64/amd64/') | ||
# Install Prereq Packages | ||
export DEBIAN_PRIORITY=critical | ||
export DEBIAN_FRONTEND=noninteractive | ||
export DEBCONF_NONINTERACTIVE_SEEN=true | ||
APT_OPTS="--yes --force-yes --no-install-suggests --no-install-recommends" | ||
APT_OPTIONS='--assume-yes --no-install-suggests --no-install-recommends' | ||
echo "Upgrading packages ..." | ||
apt-get update ${APT_OPTS} >/dev/null | ||
apt-get upgrade ${APT_OPTS} >/dev/null | ||
apt-get update -qq $APT_OPTIONS &>/dev/null | ||
apt-get upgrade -qq $APT_OPTIONS \ | ||
-o Dpkg::Options::='--force-confdef' \ | ||
-o Dpkg::Options::='--force-confold' &>/dev/null | ||
echo "Installing prerequisites ..." | ||
apt-get install ${APT_OPTS} build-essential curl git-core libpcre3-dev mercurial pkg-config zip >/dev/null | ||
# Install Go | ||
apt-get install -qq $APT_OPTIONS \ | ||
-o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' \ | ||
build-essential curl git-core libpcre3-dev mercurial pkg-config unzip zip &>/dev/null | ||
echo "Downloading go (${GOVERSION}) ..." | ||
wget -P /tmp --quiet "https://storage.googleapis.com/golang/go${GOVERSION}.linux-${ARCH}.tar.gz" | ||
wget -P /tmp -q --no-check-certificate \ | ||
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" | ||
# 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. | ||
mkdir -p "$SRCPATH" | ||
chown -R vagrant:vagrant "$SRCPATH" 2>/dev/null || true | ||
# ^^ silencing errors here because we expect this to fail for the shared folder | ||
chmod 775 $SRCROOT | ||
chown vagrant: $SRCROOT | ||
mkdir -p $SRCPATH | ||
chown -R vagrant: $SRCPATH &>/dev/null || true | ||
install -m0755 /dev/stdin /etc/profile.d/gopath.sh <<EOF | ||
cat <<EOF >/etc/profile.d/go.sh | ||
export GOPATH="$SRCPATH" | ||
export GOROOT="$SRCROOT" | ||
export PATH="$SRCROOT/bin:$SRCPATH/bin:\$PATH" | ||
export PATH="${SRCROOT}/bin:${SRCPATH}/bin:${PATH}" | ||
EOF | ||
cat >>/home/vagrant/.bashrc <<EOF | ||
chmod 755 /etc/profile.d/go.sh | ||
## After login, change to terraform directory | ||
(echo; cat <<'EOF') >>/home/vagrant/.bashrc | ||
# After login, change to Terraform sources directory. | ||
cd /opt/gopath/src/github.com/hashicorp/terraform | ||
EOF | ||
SCRIPT | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
config.vm.box = "bento/ubuntu-14.04" | ||
config.vm.hostname = "terraform" | ||
Vagrant.configure('2') do |config| | ||
config.vm.box = 'bento/ubuntu-14.04' | ||
config.vm.hostname = 'terraform' | ||
|
||
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 | ||
|
||
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 | ||
config.vm.synced_folder '.', '/opt/gopath/src/github.com/hashicorp/terraform' | ||
|
||
config.vm.provider "docker" do |v, override| | ||
override.vm.box = "tknerr/baseimage-ubuntu-14.04" | ||
if config.vm.respond_to? :use_linked_clone | ||
config.use_linked_clone = true | ||
end | ||
|
||
config.vm.provider 'docker' do |v, override| | ||
override.vm.box = 'tknerr/baseimage-ubuntu-14.04' | ||
end | ||
|
||
["vmware_fusion", "vmware_workstation"].each do |p| | ||
config.vm.provider p do |v| | ||
v.vmx["memsize"] = "4096" | ||
v.vmx["numvcpus"] = "2" | ||
%w(vmware_fusion vmware_workstation).each do |p| | ||
config.vm.provider p do |vm| | ||
vm.linked_clone = true if Vagrant::VERSION =~ /^1.8/ | ||
vm.vmx['memsize'] = '4096' | ||
vm.vmx['numvcpus'] = '2' | ||
end | ||
end | ||
|
||
config.vm.provider "virtualbox" do |v| | ||
v.memory = 4096 | ||
v.cpus = 2 | ||
config.vm.provider 'virtualbox' do |vm| | ||
vm.linked_clone = true if Vagrant::VERSION =~ /^1.8/ | ||
vm.cpus = 2 | ||
vm.memory = 4096 | ||
vm.customize [ 'modifyvm', :id, | ||
'--rtcuseutc', 'on', | ||
'--natdnsproxy1', 'on', | ||
'--natdnshostresolver1', 'on', | ||
'--nictype1', 'virtio' | ||
] | ||
end | ||
|
||
config.vm.provider "parallels" do |prl| | ||
prl.memory = 4096 | ||
prl.cpus = 2 | ||
config.vm.provider 'parallels' do |vm| | ||
vm.cpus = 2 | ||
vm.memory = 4096 | ||
end | ||
end |