summaryrefslogtreecommitdiffstats
path: root/roles/go/tasks/main.yml
blob: d4efd1dad6df30dc4ca7a938b27d58e212f902f6 (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
---
- name: "Check installed go versions"
  ansible.builtin.command:
    cmd: "mise ls go"
  register: go_installed_versions
  changed_when: false

- name: "Install go versions"
  ansible.builtin.command:
    cmd: "mise use --global go@{{ item }}"
  changed_when: true
  when: item not in go_installed_versions.stdout
  loop: "{{ go_versions }}"

- name: "Add Go bin to shell profile"
  ansible.builtin.blockinfile:
    path: "{{ ansible_facts['env']['HOME'] }}/.bashrc"
    state: "present"
    prepend_newline: true
    append_newline: true
    marker: "# ==== {mark} ANSIBLE GO CONFIG"
    block: |
      if [ -d "$HOME/go/bin" ]; then
        export PATH="$HOME/go/bin:$PATH"
      fi