---
- name: Include the vars file
  include_vars: "main.yml"

- name: Register the current Go version (if any)
  command: "{{ home }}/go version"
  ignore_errors: yes
  register: go_version
  changed_when: false

# grab the compile reqs
- include: "Darwin_compile_reqs.yml"
  when: os_family == "Darwin"

- include: "RedHat_compile_reqs.yml"
  when: os_family == "RedHat"

- include: "Debian_compile_reqs.yml"
  when: os_family == "Debian"

- name: compile go if we need to
  include: compile.yml
  when: go_version|failed or go_version_target not in go_version.stdout

- name: Add the Go bin script (sets up GOPATH, etc.) to .bash.d
  template: >
    src=99_go.bash
    dest={{ home }}/
    force=yes

- name: make sure {{ home }}/managed-bin and code/go/bin exists
  file: >
    path={{ item }}
    state=directory
  with_items:
    - "{{ home }}/managed-bin"
    - "{{ home }}/code/go"

- name: link the $GOPATH/bin/ dir to {{ home }}/managed-bin
  file: >
    src={{ home }}/managed-bin/
    dest={{ home }}/code/go/bin
    state=link

- include: go-get.yml

---
- name: Include the vars file
  include_vars: "main.yml"

- name: Register the current Go version (if any)
  command: "{{ home }}/src/go/bin/go version"
  ignore_errors: yes
  register: go_version
  changed_when: false

# grab the compile reqs
- include: "Darwin_compile_reqs.yml"
  when: os_family == "Darwin"

- include: "RedHat_compile_reqs.yml"
  when: os_family == "RedHat"

- include: "Debian_compile_reqs.yml"
  when: os_family == "Debian"

- name: compile go if we need to
  include: compile.yml
  when: go_version|failed or go_version_target not in go_version.stdout

- name: Add the Go bin script (sets up GOPATH, etc.) to .bash.d
  template: >
    src=99_go.bash
    dest={{ home }}/.bash.d/
    force=yes

- name: make sure {{ home }}/managed-bin and code/go/bin exists
  file: >
    path={{ item }}
    state=directory
  with_items:
    - "{{ home }}/managed-bin"
    - "{{ home }}/code/go"

- name: link the $GOPATH/bin/ dir to {{ home }}/managed-bin
  file: >
    src={{ home }}/managed-bin/
    dest={{ home }}/code/go/bin
    state=link

- include: go-get.yml

Use the new {{ home }} var in Go
Use the new {{ home }} var in Go
