|
5 | 5 | ignore_errors: true |
6 | 6 | changed_when: false |
7 | 7 |
|
8 | | -- name: Install uv using the official standalone installer |
9 | | - shell: "curl -fsSL {{ uv_install_script_url }} | sh" |
10 | | - register: uv_install_result |
11 | | - when: uv_check.rc != 0 |
12 | | - environment: |
13 | | - UV_INSTALL_DIR: "{{ ansible_env.HOME }}/.local/bin" |
14 | | - args: |
15 | | - executable: /bin/bash |
16 | | - |
17 | | -- name: Add uv shell completion for zsh |
18 | | - lineinfile: |
19 | | - path: "{{ ansible_env.HOME }}/.zshrc" |
20 | | - line: 'eval "$(uv generate-shell-completion zsh)"' |
21 | | - create: true |
22 | | - when: uv_check.rc == 0 or uv_install_result.changed |
23 | | - |
24 | | -- name: Add uv shell completion for bash |
25 | | - lineinfile: |
26 | | - path: "{{ ansible_env.HOME }}/.bashrc" |
27 | | - line: 'eval "$(uv generate-shell-completion bash)"' |
28 | | - create: true |
29 | | - when: uv_check.rc == 0 or uv_install_result.changed |
| 8 | +- name: Create temporary directory for uv download |
| 9 | + tempfile: |
| 10 | + state: directory |
| 11 | + suffix: uv_download |
| 12 | + register: uv_temp_dir |
| 13 | + when: uv_check.rc != 0 or uv_version not in uv_check.stdout |
| 14 | + |
| 15 | +- name: Download uv tarball |
| 16 | + get_url: |
| 17 | + url: "{{ uv_download_url }}" |
| 18 | + dest: "{{ uv_temp_dir.path }}/uv.tar.gz" |
| 19 | + checksum: "{{ uv_checksum }}" |
| 20 | + mode: '0644' |
| 21 | + when: uv_check.rc != 0 or uv_version not in uv_check.stdout |
| 22 | + |
| 23 | +- name: Extract uv tarball |
| 24 | + unarchive: |
| 25 | + src: "{{ uv_temp_dir.path }}/uv.tar.gz" |
| 26 | + dest: "{{ uv_temp_dir.path }}" |
| 27 | + remote_src: true |
| 28 | + when: uv_check.rc != 0 or uv_version not in uv_check.stdout |
| 29 | + |
| 30 | +- name: Install uv binary |
| 31 | + copy: |
| 32 | + src: "{{ uv_temp_dir.path }}/uv-{{ uv_platform }}/uv" |
| 33 | + dest: "{{ uv_install_dir }}/uv" |
| 34 | + mode: '0755' |
| 35 | + when: uv_check.rc != 0 or uv_version not in uv_check.stdout |
| 36 | + |
| 37 | +- name: Install uvx binary |
| 38 | + copy: |
| 39 | + src: "{{ uv_temp_dir.path }}/uv-{{ uv_platform }}/uvx" |
| 40 | + dest: "{{ uv_install_dir }}/uvx" |
| 41 | + mode: '0755' |
| 42 | + when: uv_check.rc != 0 or uv_version not in uv_check.stdout |
30 | 43 |
|
31 | 44 | - name: Verify uv installation |
32 | | - command: "{{ ansible_env.HOME }}/.local/bin/uv --version" |
| 45 | + command: "{{ uv_install_dir }}/uv --version" |
33 | 46 | register: uv_verify |
34 | 47 | changed_when: false |
35 | 48 |
|
| 49 | +- name: Clean up temporary directory |
| 50 | + file: |
| 51 | + path: "{{ uv_temp_dir.path }}" |
| 52 | + state: absent |
| 53 | + when: uv_temp_dir.path is defined |
| 54 | + |
36 | 55 | - name: Show uv version |
37 | 56 | debug: |
38 | 57 | msg: "uv installed: {{ uv_verify.stdout }}" |
0 commit comments