diff options
| author | Ahmed Abdelhalim <[email protected]> | 2025-09-15 19:27:22 +0200 |
|---|---|---|
| committer | Ahmed Abdelhalim <[email protected]> | 2025-09-15 19:27:22 +0200 |
| commit | 42899d44598c9cd848af1c86427f0b4c03f54493 (patch) | |
| tree | 09e261d0fc05fd673763b1090aca1d44b06e4460 | |
| parent | 3bd4fb05c8b98d12be1321854bfd6b8fb78307f1 (diff) | |
Fix uv idempotent install for the tool versions
| -rw-r--r-- | roles/ansible/tasks/main.yml | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/roles/ansible/tasks/main.yml b/roles/ansible/tasks/main.yml index 732cfb2e..3923fc1a 100644 --- a/roles/ansible/tasks/main.yml +++ b/roles/ansible/tasks/main.yml @@ -6,18 +6,48 @@ - molecule_version | regex_search('^[0-9]+\\.[0-9]+\\.[0-9]+$') is not none msg: "Version must be in major.minor.patch format" -- name: "Install ansible core" - ansible.builtin.command: - cmd: "uv tool install ansible-core=={{ ansible_core_version }}" +- name: "Check ansible-core version {{ ansible_core_version }}" + ansible.builtin.shell: | + set -euo pipefail + uv tool list | grep "^ansible-core " | awk '{print $2}' | sed 's/^v//' args: - creates: "{{ ansible_env.HOME }}/.local/bin/ansible-core" + executable: /bin/bash environment: PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" + register: ansible_core_installed_version + changed_when: false + failed_when: false -- name: "Install molecule" - ansible.builtin.command: - cmd: "uv tool install molecule=={{ molecule_version }} --with 'molecule-plugins[docker,podman]'" +- name: "Install ansible core version {{ ansible_core_version }}" + ansible.builtin.shell: | + set -euo pipefail + uv tool install ansible-core=={{ ansible_core_version }} args: - creates: "{{ ansible_env.HOME }}/.local/bin/molecule" + executable: /bin/bash environment: PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" + changed_when: true + when: ansible_core_installed_version.stdout != ansible_core_version + +- name: "Check molecule version {{ molecule_version }}" + ansible.builtin.shell: | + set -euo pipefail + 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 + +- name: "Install molecule version {{ molecule_version }}" + ansible.builtin.shell: | + set -euo pipefail + uv tool install molecule=={{ molecule_version }} --with 'molecule-plugins[docker,podman]' + args: + executable: /bin/bash + environment: + PATH: "/home/linuxbrew/.linuxbrew/bin:{{ ansible_env.PATH }}" + changed_when: true + when: molecule_installed_version.stdout != molecule_version |
