Skip to content

Instantly share code, notes, and snippets.

@eiri
Last active October 8, 2017 20:16
Show Gist options
  • Save eiri/a0504f8814c2760cb23d7e1107c88d9c to your computer and use it in GitHub Desktop.
Save eiri/a0504f8814c2760cb23d7e1107c88d9c to your computer and use it in GitHub Desktop.
Vagrant setup for go dev

Vagrant setup for go dev

Overview

  • Linux: Debian Stretch
  • Provisioning: Ansible
  • Go: 1.9.1

Pre-requirements

  • VirtualBox: 5.1.28
  • Vagrant: 2.0.0
  • Vagrant plugins: vagrant-share 1.1.9
  • Ansible: 2.2.1.0

Install

git clone https://gist.github.com/eiri/a0504f8814c2760cb23d7e1107c88d9c.git goalie
cd goalie
mkdir git
vagrant up
vagrant ssh
go version
.vagrant/
git/
---
- hosts: all
remote_user: vagrant
become: yes
tasks:
- name: update packages dist
apt:
update_cache: yes
- name: install all packages
apt:
name: "{{item}}"
state: present
with_items:
- git
- build-essential
- make
- curl
- wget
- vim
- tree
- multitail
- name: install golang
unarchive:
src: https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
dest: /opt
copy: no
creates: /opt/go
- name: update .bash_aliases
become_user: vagrant
lineinfile:
dest: /home/vagrant/.bash_aliases
line: 'alias lt="ls -Gltr"'
mode: 0644
state: present
create: yes
- name: add local ~/bin
become_user: vagrant
file:
path: /home/vagrant/bin
state: directory
mode: 0755
- name: build go workspace
become_user: vagrant
file:
path: "/home/vagrant/git/{{item}}"
state: directory
mode: 0755
with_items:
- bin
- pkg
- src
- name: add $GOROOT
become_user: vagrant
lineinfile:
dest: /home/vagrant/.bashrc
line: export GOROOT=/opt/go
- name: add $GOPATH
become_user: vagrant
lineinfile:
dest: /home/vagrant/.bashrc
line: export GOPATH=$HOME/git
- name: update $PATH
become_user: vagrant
lineinfile:
dest: /home/vagrant/.profile
line: export PATH=$HOME/bin:$GOPATH/bin:$GOROOT/bin:$PATH
Vagrant.configure(2) do |config|
config.vm.box = "debian/stretch64"
config.vm.box_check_update = true
config.vm.hostname = "goalie.dev"
config.ssh.shell = "/bin/bash"
config.vm.network "private_network", ip: '192.168.10.2'
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.synced_folder "git/", "/home/vagrant/git", type: "nfs", mount_options: ["nolock", "vers=3", "tcp", "noatime", "actimeo=1"]
config.vm.provider "virtualbox" do |vb|
vb.name = "goalie"
vb.gui = false
vb.cpus = 1
vb.memory = 4096
vb.customize ["modifyvm", :id, "--vram", "9"]
vb.customize ["modifyvm", :id, "--vrde", "off"]
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "provision.yml"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment