blob: 13612f2964f4d5b6fb4b49fbc815a621f4fe0e55 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
---
- name: "Install latest Go via Homebrew"
community.general.homebrew:
name: "go"
state: "present"
- name: "Add Go to shell profile"
ansible.builtin.blockinfile:
path: "{{ ansible_env.HOME }}/.bashrc"
state: "present"
prepend_newline: true
append_newline: true
marker: "# ==== {mark} ANSIBLE GO CONFIG"
block: |
if command -v go 1>/dev/null 2>&1; then
export PATH="$HOME/go/bin:$PATH"
export PATH="$HOME/sdk/*/bin:$PATH"
fi
- name: "Install Go version managers"
ansible.builtin.command:
cmd: "go install golang.org/dl/go{{ item }}@latest"
args:
creates: "{{ ansible_env.HOME }}/go/bin/go{{ item }}"
environment:
PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
with_items: "{{ go_versions }}"
when: go_versions | length > 0
- name: "Download and install Go versions"
ansible.builtin.command:
cmd: "{{ ansible_env.HOME }}/go/bin/go{{ item }} download"
args:
creates: "{{ ansible_env.HOME }}/sdk/go{{ item }}/bin/go"
environment:
PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
with_items: "{{ go_versions }}"
when: go_versions | length > 0
|