Skip to content

Instantly share code, notes, and snippets.

@nomasprime
Last active May 6, 2016 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomasprime/bc10eff328345378448f671dc8cbaae2 to your computer and use it in GitHub Desktop.
Save nomasprime/bc10eff328345378448f671dc8cbaae2 to your computer and use it in GitHub Desktop.
---
- name: goenv checkout repo
git:
dest: "{{ ansible_env.HOME }}/.goenv"
repo: "https://github.com/syndbg/goenv.git"
- name: goenv update profile
lineinfile:
create: yes
dest: "{{ ansible_env.HOME }}/.bash_profile"
line: "{{ item.line }}"
regexp: "{{ item.regexp }}"
with_items:
- { line: 'export GOENV_ROOT="$HOME/.goenv"', regexp: '^export GOENV_ROOT="\$HOME/\.goenv"' }
- { line: 'export PATH="$GOENV_ROOT/bin:$PATH"', regexp: '^export PATH="\$GOENV_ROOT/bin:\$PATH"' }
- { line: eval "$(goenv init -)", regexp: 'eval "\$\(goenv init -\)"' }
- block:
- name: golang installed versions
command: goenv versions
ignore_errors: yes
register: golang_installed_versions
- name: golang install versions
command: goenv install {{ item.key }}
when:
(golang.versions is defined) and
(golang_installed_versions.stdout.find(item.key) == -1)
with_dict: "{{ golang.versions }}"
- name: golang global version
command: goenv global {{ golang.global_version }}
when:
(golang.global_version is defined) and
(golang_installed_versions.stdout.find('* ' + golang.global_version) == -1)
- name: golang local versions
command: goenv local {{ item.0 }} chdir={{ item.1 }}
ignore_errors: yes
with_subelements:
- "{{ golang.versions }}"
- paths
- flags:
skip_missing: true
environment:
PATH: "{{ ansible_env.PATH }}:{{ ansible_env.HOME }}/.goenv/bin"
---
golang:
versions:
- user: vagrant
installs:
- version: 1.6.1
paths:
- /vagrant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment