Skip to content

Bootstrap Ubuntu Testing Environment

Brian Hicks edited this page Dec 22, 2016 · 2 revisions

The following Vagrantfile will set up a simple testing environment with Go 1.7 installed and Converge checked out at /home/vagrant/go/github.com/asteris-llc/converge. Substitute in whichever ubuntu image you want to use.

# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu-14.04"

  config.vm.provision "shell", privileged: false, inline: <<-SHELL
    # install Go
    test -d /usr/local/go || (cd /tmp; wget -qO go.tgz https://storage.googleapis.com/golang/go1.7.linux-amd64.tar.gz && tar -xzf go.tgz && sudo mv go /usr/local/ && rm go.tgz)

    # set environment variables
    echo 'export GOROOT=/usr/local/go'   | sudo tee /etc/profile.d/go.sh
    echo 'export PATH=$GOROOT/bin:$PATH' | sudo tee -a /etc/profile.d/go.sh
    source /etc/profile.d/go.sh

    # create GOPATH
    mkdir -p ~/go/{src,bin}
    echo ''                              >> ~/.profile
    echo '# Go'                          >> ~/.profile
    echo 'export GOPATH=$HOME/go'        >> ~/.profile
    echo 'export PATH=$GOPATH/bin:$PATH' >> ~/.profile
    source ~/.profile

    # install glide
    which glide || curl https://glide.sh/get | sh

    # get Converge
    go get -v -d github.com/asteris-llc/converge
  SHELL
end
Clone this wiki locally