summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-09-02 20:01:04 +0200
committerAhmed Abdelhalim <[email protected]>2025-09-02 21:16:01 +0200
commitef64f48a1fdac5a8ad1580991048c1e5d7932f0f (patch)
tree594047268af50dc908b852f8ae0852ca9737e8a0
parentbcfbf44b501281ba9db8c6cfb0da08c169c770aa (diff)
Fix homebrew to use commands instead of module to avoid issue with arch
Plus it's cleaner to see what gets installed instead of depending on the module
-rw-r--r--roles/go/tasks/main.yml20
-rw-r--r--roles/homebrew/tasks/main.yml22
-rw-r--r--roles/python/tasks/main.yml29
3 files changed, 30 insertions, 41 deletions
diff --git a/roles/go/tasks/main.yml b/roles/go/tasks/main.yml
index 52854f8f..a7fd08d4 100644
--- a/roles/go/tasks/main.yml
+++ b/roles/go/tasks/main.yml
@@ -15,30 +15,26 @@
when: go_versions | length == 0
block:
- name: "Install latest Go"
- community.general.homebrew:
- name: "go"
- state: "present"
+ ansible.builtin.command:
+ cmd: "/home/linuxbrew/.linuxbrew/bin/brew install go"
+ creates: "/home/linuxbrew/.linuxbrew/bin/go"
- name: "Set latest Go as global version"
ansible.builtin.command:
- cmd: "brew link --force go"
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
+ cmd: "/home/linuxbrew/.linuxbrew/bin/brew link --force go"
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"
+ ansible.builtin.command:
+ cmd: "/home/linuxbrew/.linuxbrew/bin/brew install go@{{ item }}"
+ creates: "/home/linuxbrew/.linuxbrew/Cellar/go@{{ item }}"
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 }}"
+ cmd: "/home/linuxbrew/.linuxbrew/bin/brew link --force go@{{ go_global_version }}"
when: go_global_version != ""
changed_when: true
diff --git a/roles/homebrew/tasks/main.yml b/roles/homebrew/tasks/main.yml
index 7dc273be..ce5932a5 100644
--- a/roles/homebrew/tasks/main.yml
+++ b/roles/homebrew/tasks/main.yml
@@ -40,14 +40,14 @@
environment:
NONINTERACTIVE: "1"
- - name: "Add homebrew to shell profile"
- ansible.builtin.blockinfile:
- path: "{{ ansible_env.HOME }}/.bashrc"
- state: "present"
- prepend_newline: true
- append_newline: true
- marker: "# ==== {mark} ANSIBLE HOMEBREW CONFIG"
- create: true
- mode: "0644"
- block: |
- eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
+- name: "Add homebrew to shell profile"
+ ansible.builtin.blockinfile:
+ path: "{{ ansible_env.HOME }}/.bashrc"
+ state: "present"
+ prepend_newline: true
+ append_newline: true
+ marker: "# ==== {mark} ANSIBLE HOMEBREW CONFIG"
+ create: true
+ mode: "0644"
+ block: |
+ eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
diff --git a/roles/python/tasks/main.yml b/roles/python/tasks/main.yml
index d2dfc9a9..a252a374 100644
--- a/roles/python/tasks/main.yml
+++ b/roles/python/tasks/main.yml
@@ -1,10 +1,11 @@
---
- name: "Install pyenv and pipx"
- community.general.homebrew:
- name:
- - "pyenv"
- - "pipx"
- state: "present"
+ ansible.builtin.command:
+ cmd: "/home/linuxbrew/.linuxbrew/bin/brew install {{ item }}"
+ creates: "/home/linuxbrew/.linuxbrew/bin/{{ item }}"
+ with_items:
+ - "pyenv"
+ - "pipx"
- name: "Add pyenv to shell profile"
ansible.builtin.blockinfile:
@@ -34,9 +35,7 @@
- name: "Get installed python versions"
ansible.builtin.command:
- cmd: "pyenv versions --bare"
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
+ cmd: "/home/linuxbrew/.linuxbrew/bin/pyenv versions --bare"
register: installed_python_versions
changed_when: false
failed_when: false
@@ -45,9 +44,7 @@
vars:
major_minor: "{{ item | regex_replace('^([0-9]+\\.[0-9]+).*', '\\1') }}"
ansible.builtin.command:
- cmd: "pyenv uninstall -f {{ item }}"
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
+ cmd: "/home/linuxbrew/.linuxbrew/bin/pyenv uninstall -f {{ item }}"
loop: "{{ installed_python_versions.stdout_lines | default([]) }}"
when:
- installed_python_versions.rc == 0
@@ -58,16 +55,12 @@
- name: "Install python versions"
ansible.builtin.command:
- cmd: "pyenv install {{ item }}"
+ cmd: "/home/linuxbrew/.linuxbrew/bin/pyenv install {{ item }}"
args:
creates: "{{ ansible_env.HOME }}/.pyenv/versions/{{ item }}*/bin/python"
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
with_items: "{{ python_versions }}"
- name: "Set global python version"
ansible.builtin.command:
- cmd: "pyenv global {{ python_global_version }}"
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
- changed_when: false
+ cmd: "/home/linuxbrew/.linuxbrew/bin/pyenv global {{ python_global_version }}"
+ changed_when: true