summaryrefslogtreecommitdiffstats
path: root/roles/go/tasks
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-09-02 23:45:06 +0200
committerAhmed Abdelhalim <[email protected]>2025-09-03 00:22:04 +0200
commitefc6816cb85c3bfb462265dea114e79ec736d2cd (patch)
tree3c51d3c523902f72b8fa27a3753010540fdec37c /roles/go/tasks
parent1e8ff97dc4e815d3cdf769089413704891e6b152 (diff)
Revert back to using brew module as it has better idempotency handling
Diffstat (limited to 'roles/go/tasks')
-rw-r--r--roles/go/tasks/main.yml36
1 files changed, 18 insertions, 18 deletions
diff --git a/roles/go/tasks/main.yml b/roles/go/tasks/main.yml
index 99b00be1..84ade883 100644
--- a/roles/go/tasks/main.yml
+++ b/roles/go/tasks/main.yml
@@ -22,28 +22,28 @@
failed_when: false
- name: "Remove unwanted Go versions"
- ansible.builtin.command:
- cmd: "/home/linuxbrew/.linuxbrew/bin/brew uninstall go@{{ item }}"
+ community.general.homebrew:
+ name: "go@{{ item }}"
+ state: "absent"
with_items: "{{ go_installed_versions.stdout_lines | default([]) }}"
when:
- go_installed_versions.rc == 0
- item not in go_versions
- changed_when: true
- name: "Install and configure Go latest"
when: go_versions | length == 0
block:
- name: "Install latest Go"
- ansible.builtin.command:
- cmd: "/home/linuxbrew/.linuxbrew/bin/brew install go"
- creates: "/home/linuxbrew/.linuxbrew/bin/go"
+ community.general.homebrew:
+ name: "go"
+ state: "present"
- name: "Set latest Go as global version"
- ansible.builtin.command:
- cmd: "/home/linuxbrew/.linuxbrew/bin/brew link --force go"
+ community.general.homebrew:
+ name: "go"
+ state: "linked"
# The set global version always run and is always changing the system
# It's intentional to ignore this task for idempotency test
- changed_when: true
tags:
- molecule-idempotence-notest
@@ -51,24 +51,24 @@
when: go_versions | length > 0
block:
- name: "Install specific Go versions"
- ansible.builtin.command:
- cmd: "/home/linuxbrew/.linuxbrew/bin/brew install go@{{ item }}"
- creates: "/home/linuxbrew/.linuxbrew/Cellar/go@{{ item }}"
+ community.general.homebrew:
+ name: "go@{{ item }}"
+ state: "present"
with_items: "{{ go_versions }}"
- name: "Unlink existing Go package"
- ansible.builtin.command:
- cmd: "/home/linuxbrew/.linuxbrew/bin/brew unlink go"
+ community.general.homebrew:
+ name: "go"
+ state: "unlinked"
when: go_global_version != ""
failed_when: false
- changed_when: false
- name: "Set specific Go version as global"
- ansible.builtin.command:
- cmd: "/home/linuxbrew/.linuxbrew/bin/brew link --overwrite go@{{ go_global_version }}"
+ community.general.homebrew:
+ name: "go@{{ go_global_version }}"
+ state: "linked"
when: go_global_version != ""
# The set global version always run and is always changing the system
# It's intentional to ignore this task for idempotency test
- changed_when: true
tags:
- molecule-idempotence-notest