summaryrefslogtreecommitdiffstats
path: root/roles/python/tasks/main.yml
blob: 55f4e34a3b5f16ccbcfdb7213c96eb60f35babe8 (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
31
32
33
34
35
---
- name: "Include OS-specific variables"
  ansible.builtin.include_vars: "{{ ansible_os_family | lower }}.yml"

- 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:
    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{{ item }}"
  loop: "{{ python_versions }}"
  when: python_versions | length > 0