summaryrefslogtreecommitdiffstats
path: root/roles/python
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
commitc4abe4f47d78119a86185b355d2f43dc4ac4dd35 (patch)
tree594047268af50dc908b852f8ae0852ca9737e8a0 /roles/python
parentf24e3a4409c98e84cae4c0407ed6958cb470ecfb (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
Diffstat (limited to 'roles/python')
-rw-r--r--roles/python/tasks/main.yml29
1 files changed, 11 insertions, 18 deletions
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