diff options
| author | Ahmed Abdelhalim <[email protected]> | 2025-09-02 19:25:26 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2025-09-02 19:25:26 +0200 |
| commit | bcfbf44b501281ba9db8c6cfb0da08c169c770aa (patch) | |
| tree | 66589d44a29033692382ea635fa0f443ccb2cb3d /roles/go/tasks | |
| parent | e1d3cc942662a132d8a86d3211857ab5e92d296e (diff) | |
Update the go role to handle default to latest
Diffstat (limited to 'roles/go/tasks')
| -rw-r--r-- | roles/go/tasks/main.yml | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/roles/go/tasks/main.yml b/roles/go/tasks/main.yml index 27515584..52854f8f 100644 --- a/roles/go/tasks/main.yml +++ b/roles/go/tasks/main.yml @@ -11,15 +11,34 @@ export PATH="$HOME/go/bin:$PATH" fi -- name: "Instal Go versions" - community.general.homebrew: - name: - - "go@{{ item }}" - with_items: "{{ go_versions }}" +- name: "Install and configure Go latest" + when: go_versions | length == 0 + block: + - name: "Install latest Go" + community.general.homebrew: + name: "go" + state: "present" -- name: "Set global go version" - ansible.builtin.command: - cmd: "brew link go@{{ go_global_version }}" - environment: - PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" - changed_when: false + - name: "Set latest Go as global version" + ansible.builtin.command: + cmd: "brew link --force go" + environment: + PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" + changed_when: true + +- name: "Install and configure Go versions" + when: go_versions | length > 0 + block: + - name: "Install specific Go versions" + community.general.homebrew: + name: "go@{{ item }}" + state: "present" + with_items: "{{ go_versions }}" + + - name: "Set specific Go version as global" + ansible.builtin.command: + cmd: "brew link --force go@{{ go_global_version }}" + environment: + PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" + when: go_global_version != "" + changed_when: true |
