Fix ansible version detection for uv-managed environments

Replace pip_package_info lookup with uv pip list command to detect ansible version.
This fixes "'dict object' has no attribute 'ansible'" error on macOS where
ansible is installed via uv instead of system pip.

The fix extracts the ansible package version (e.g. 11.8.0) from uv pip list
output instead of trying to access non-existent pip package registry.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Dan Guido 2025-08-05 16:06:38 -07:00
parent 2efaa25c56
commit 32cc00c9fb

View file

@ -33,9 +33,14 @@
ver: "{{ ansible_requirement | regex_replace('^ansible\\s*[~>=<]+\\s*(\\d+\\.\\d+(?:\\.\\d+)?).*$', '\\1') }}"
when: ansible_requirement is defined
- name: Just get the list from default pip
community.general.pip_package_info:
register: pip_package_info
- name: Get current ansible package version
command: uv pip list
register: uv_package_list
changed_when: false
- name: Extract ansible version from uv package list
set_fact:
current_ansible_version: "{{ uv_package_list.stdout | regex_search('ansible\\s+([0-9]+\\.[0-9]+\\.[0-9]+)', '\\1') | first }}"
- name: Verify Python meets Algo VPN requirements
assert:
@ -48,10 +53,10 @@
- name: Verify Ansible meets Algo VPN requirements
assert:
that:
- pip_package_info.packages.pip.ansible.0.version is version(required_ansible_version.ver, required_ansible_version.op)
- current_ansible_version is version(required_ansible_version.ver, required_ansible_version.op)
- not ipaddr.failed
msg: >
Ansible version is {{ pip_package_info.packages.pip.ansible.0.version }}.
Ansible version is {{ current_ansible_version }}.
You must update the requirements to use this version of Algo.
Try to run: uv sync