summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-10-20 00:06:49 +0200
committerAhmed Abdelhalim <[email protected]>2025-10-20 00:48:59 +0200
commit806deb655dc2cce32ceffde65ebb7abe88937da1 (patch)
treef7fc2ca0796f18d5f95fb3346feb7a931c8331e9
parentcf400c3e738f9660cc76e9fad82c4654acca2583 (diff)
Refactor python role to remove homebrew dependency
-rw-r--r--configure.yml4
-rw-r--r--roles/ansible/README.md26
-rw-r--r--roles/ansible/tasks/main.yml8
-rw-r--r--roles/python/meta/main.yml3
-rw-r--r--roles/python/tasks/main.yml17
5 files changed, 20 insertions, 38 deletions
diff --git a/configure.yml b/configure.yml
index de84c5b5..2e4ef676 100644
--- a/configure.yml
+++ b/configure.yml
@@ -3,6 +3,8 @@
gather_facts: true
hosts:
- archlinux.local
+ environment:
+ PATH: "{{ ansible_env.HOME }}/.local/bin:{{ ansible_env.PATH }}"
roles:
- role: "locales"
- role: "timezone"
@@ -18,6 +20,8 @@
gather_facts: true
hosts:
- ubuntu.local
+ environment:
+ PATH: "{{ ansible_env.HOME }}/.local/bin:{{ ansible_env.PATH }}"
roles:
- role: "locales"
- role: "timezone"
diff --git a/roles/ansible/README.md b/roles/ansible/README.md
index 8e6f3a6e..1234be86 100644
--- a/roles/ansible/README.md
+++ b/roles/ansible/README.md
@@ -60,32 +60,12 @@ To switch the default version:
The symlinks will be updated to point to the new default versions.
-## Manual Cleanup
-
-This role does not automatically remove unused versions. To manually clean up old installations:
-
-### List installed versions
-
-```bash
-pipx list --short
-```
-
-### Remove specific versions
-
-```bash
-# Remove ansible-core versions
-pipx uninstall ansible-core2.18.0
-
-# Remove molecule versions
-pipx uninstall molecule25.7.0
-```
-
## Requirements
-- pipx must be installed and available at `/home/linuxbrew/.linuxbrew/bin/pipx`
-- The `community.general` Ansible collection for the pipx module
+- `uv`
+- `python`
-These requirements are satisfied with the `homebrew` and `python` roles (added as dependencies)
+These are installed via `python` role
## Example Playbook
diff --git a/roles/ansible/tasks/main.yml b/roles/ansible/tasks/main.yml
index fa1de1b7..335dba72 100644
--- a/roles/ansible/tasks/main.yml
+++ b/roles/ansible/tasks/main.yml
@@ -12,8 +12,6 @@
uv tool list | grep "^ansible-core " | awk '{print $2}' | sed 's/^v//'
args:
executable: /bin/bash
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
register: ansible_core_installed_version
changed_when: false
failed_when: false
@@ -24,8 +22,6 @@
uv tool install ansible-core=={{ ansible_core_version }} --force
args:
executable: /bin/bash
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
changed_when: true
when: ansible_core_installed_version.stdout != ansible_core_version
@@ -35,8 +31,6 @@
uv tool list | grep "^molecule " | awk '{print $2}' | sed 's/^v//'
args:
executable: /bin/bash
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
register: molecule_installed_version
changed_when: false
failed_when: false
@@ -47,7 +41,5 @@
uv tool install molecule=={{ molecule_version }} --with 'molecule-plugins[docker,podman]' --force
args:
executable: /bin/bash
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
changed_when: true
when: molecule_installed_version.stdout != molecule_version
diff --git a/roles/python/meta/main.yml b/roles/python/meta/main.yml
index 4cbc7559..20f1f049 100644
--- a/roles/python/meta/main.yml
+++ b/roles/python/meta/main.yml
@@ -1,6 +1,7 @@
---
dependencies:
- - role: "homebrew"
+ - role: "bash"
+ - role: "curl"
galaxy_info:
author: "a14m"
description: "Install uv and python (versions) on Linux distributions"
diff --git a/roles/python/tasks/main.yml b/roles/python/tasks/main.yml
index b469c9d2..55f4e34a 100644
--- a/roles/python/tasks/main.yml
+++ b/roles/python/tasks/main.yml
@@ -2,10 +2,17 @@
- name: "Include OS-specific variables"
ansible.builtin.include_vars: "{{ ansible_os_family | lower }}.yml"
-- name: "Install uv"
- community.general.homebrew:
- name: "uv"
- state: "present"
+- name: "Download uv installer"
+ ansible.builtin.get_url:
+ url: "https://astral.sh/uv/install.sh"
+ dest: "/tmp/install_uv.sh"
+ mode: "0755"
+
+- name: "Run uv installer"
+ ansible.builtin.command:
+ cmd: "/tmp/install_uv.sh"
+ args:
+ creates: "{{ ansible_env.HOME }}/.local/bin/uv"
- name: "Add uv to shell profile"
ansible.builtin.blockinfile:
@@ -24,7 +31,5 @@
cmd: "uv python install {{ item }}"
args:
creates: "{{ ansible_env.HOME }}/.local/share/uv/python/cpython-{{ item }}*/bin/python{{ item }}"
- environment:
- PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
loop: "{{ python_versions }}"
when: python_versions | length > 0