summaryrefslogtreecommitdiffstats
path: root/roles/python/tasks/main.yml
blob: 6ae2e3875e3b815de73e635e33172610420af850 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
---
- 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: "Add uv to shell profile"
  ansible.builtin.blockinfile:
    path: "{{ ansible_env.HOME }}/.bashrc"
    state: "present"
    prepend_newline: true
    append_newline: true
    marker: "# ==== {mark} ANSIBLE UV PYTHON CONFIG"
    block: |
      if command -v uv 1>/dev/null 2>&1; then
        export PATH="$HOME/.local/bin:$PATH"
      fi

- name: "Install python versions"
  ansible.builtin.command:
    cmd: "uv python install {{ item }}"
  args:
    creates: "{{ ansible_env.HOME }}/.local/share/uv/python/cpython-{{ item }}-*/bin/python"
  environment:
    PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}"
  with_items: "{{ python_versions }}"
  when: python_versions | length > 0