github.com/aspring/terraform@v0.8.2-0.20161216122603-6a8619a5db2e/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  install -m0755 /dev/stdin /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  
    55  cat >>/home/vagrant/.bashrc <<EOF
    56  
    57  ## After login, change to terraform directory
    58  cd /opt/gopath/src/github.com/hashicorp/terraform
    59  EOF
    60  
    61  SCRIPT
    62  
    63  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    64    config.vm.box = "bento/ubuntu-#{UBUNTUVERSION}"
    65    config.vm.hostname = "terraform"
    66  
    67    config.vm.provision "prepare-shell", type: "shell", inline: "sudo sed -i '/tty/!s/mesg n/tty -s \\&\\& mesg n/' /root/.profile", privileged: false
    68    config.vm.provision "initial-setup", type: "shell", inline: $script
    69    config.vm.synced_folder '.', '/opt/gopath/src/github.com/hashicorp/terraform'
    70  
    71    config.vm.provider "docker" do |v, override|
    72      override.vm.box = "tknerr/baseimage-ubuntu-#{UBUNTUVERSION}"
    73    end
    74  
    75    ["vmware_fusion", "vmware_workstation"].each do |p|
    76      config.vm.provider p do |v|
    77        v.vmx["memsize"] = "#{RAM}"
    78        v.vmx["numvcpus"] = "#{CPUCOUNT}"
    79      end
    80    end
    81  
    82    config.vm.provider "virtualbox" do |v|
    83      v.memory = "#{RAM}"
    84      v.cpus = "#{CPUCOUNT}"
    85    end
    86  
    87    config.vm.provider "parallels" do |prl|
    88      prl.memory = "#{RAM}"
    89      prl.cpus = "#{CPUCOUNT}"
    90    end
    91  end