
Ensure consistent and automatic creation of virtual environments when defined. Replaced manual `packaging` installation with pip module usage for better idempotency. Improved pip binary detection by deriving it from the Python executable, avoiding hardcoded 'pip3' which can point to diferrent pip version (pip3.9 instead of pip3.12 for example). Changes affect both docker_sdk and podman_sdk roles: - Automatically install both `pip` and `packaging` in the virtualenv. - Use ansible_facts.python.executable to build pip path dynamically. This improves compatibility and reduces complexity. Needed-By: https://review.opendev.org/c/openstack/kolla-ansible/+/949812 Change-Id: Ib361383bc320182e4d1ca0aa4fd4d5017215ea58
16 lines
903 B
YAML
16 lines
903 B
YAML
---
|
|
- name: Uninstall docker SDK for python using pip
|
|
pip:
|
|
name: "{{ docker_sdk_core_pip_packages }}"
|
|
executable: "{{ (virtualenv is none) | ternary(ansible_facts.python.executable | regex_replace('python(\\d+(\\.\\d+)?)$', 'pip\\1'), omit) }}"
|
|
virtualenv: "{{ virtualenv is none | ternary(omit, virtualenv) }}"
|
|
virtualenv_site_packages: "{{ virtualenv is none | ternary(omit, virtualenv_site_packages) }}"
|
|
virtualenv_command: "{{ virtualenv is none | ternary(omit, ansible_facts.python.executable ~ ' -m venv') }}"
|
|
state: absent
|
|
become: true
|
|
become_user: "{{ virtualenv is none | ternary(omit, docker_sdk_virtualenv_owner) }}"
|
|
when: not (docker_sdk_python_externally_managed | default(false) and virtualenv is none)
|
|
|
|
# NOTE(r-krcek): Don't uninstall docker_sdk_packages because that includes
|
|
# important packages like pip or setuptools that are still needed on systems!
|