skynyrd
3/13/2017 - 11:18 AM

Vagrant Usage, Bonus: GOCD agent installation

Vagrant Usage, Bonus: GOCD agent installation

  • Install Vagrant
  • Create Vagrant File in a folder, project root, e.g:
Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/xenial64"
  config.vm.provision :shell, path: "bootstrap.sh"
  config.vm.network "public_network",
    use_dhcp_assigned_default_route: true
end

Means: Take ubuntu/xenial64 image, apply bootstrap.sh, use public network.

  • Example bootstrap.sh:
#!/usr/bin/env bash
set -ex

apt-get update

# Install GOCD-Agent
echo "deb https://download.gocd.io /" | sudo tee /etc/apt/sources.list.d/gocd.list
curl https://download.gocd.io/GOCD-GPG-KEY.asc | sudo apt-key add -
sudo apt-get update

apt-get install -y go-agent

# Install Docker
apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    software-properties-common

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

sudo apt-get update
sudo apt-get install -y docker-ce=17.03.0~ce-0~ubuntu-xenial

# Install Docker Compose
curl -L https://github.com/docker/compose/releases/download/1.11.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

# Configure GOCD
cp /vagrant/go-agent /etc/default
  • go-agent
GO_SERVER_URL=https://192.168.57.165:8154/go
AGENT_WORK_DIR=/var/lib/${SERVICE_NAME:-go-agent}
DAEMON=Y
VNC=N
  • vagrant up ups the virtual machine
  • vagrant ssh connects to vagrant instance
  • vagrant destroy destroys the machine

By default, project root folder and /vagrant/go-agent folder in virtual machine are shared and synchronized.

PS. GoCD does not recognized by server after this, probably related to networking options of Virtual Box