mirror of https://github.com/ansible/ansible.git
Fix ansible-galaxy traceback when unexpected version of resolvelib is installed (#77630)
* Fix traceback when a supported version of resolvelib is not installed Try to read the supported version range from the package distribution info and fall back to a hardcoded lowerbound/upperbound (>=0.5.3,<0.6.0). * Add tests for unsupported resolvelib versions * Resolve remaining import sanity test issues. Co-authored-by: Matt Clay <matt@mystile.com> Co-authored-by: Matt Martz <matt@sivel.net>pull/77906/head
parent
621e782ed0
commit
82f3a57bee
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- ansible-galaxy - handle unsupported versions of resolvelib gracefully.
|
@ -0,0 +1,42 @@
|
||||
- vars:
|
||||
venv_cmd: "{{ ansible_python_interpreter ~ ' -m venv' }}"
|
||||
venv_dest: "{{ galaxy_dir }}/test_resolvelib_{{ resolvelib_version }}"
|
||||
block:
|
||||
- name: install another version of resolvelib that is unsupported by ansible-galaxy
|
||||
pip:
|
||||
name: resolvelib
|
||||
version: "{{ resolvelib_version }}"
|
||||
state: present
|
||||
virtualenv_command: "{{ venv_cmd }}"
|
||||
virtualenv: "{{ venv_dest }}"
|
||||
virtualenv_site_packages: True
|
||||
|
||||
- name: create test collection install directory - {{ test_name }}
|
||||
file:
|
||||
path: '{{ galaxy_dir }}/ansible_collections'
|
||||
state: directory
|
||||
|
||||
- name: install simple collection from first accessible server (expected failure)
|
||||
command: "ansible-galaxy collection install namespace1.name1 {{ galaxy_verbosity }}"
|
||||
environment:
|
||||
ANSIBLE_COLLECTIONS_PATH: '{{ galaxy_dir }}/ansible_collections'
|
||||
PATH: "{{ venv_dest }}/bin:{{ ansible_env.PATH }}"
|
||||
register: resolvelib_version_error
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- resolvelib_version_error is failed
|
||||
- compat_error in resolvelib_version_error.stderr or import_error in resolvelib_version_error.stderr
|
||||
vars:
|
||||
import_error: "Failed to import resolvelib"
|
||||
compat_error: "ansible-galaxy requires resolvelib<0.6.0,>=0.5.3"
|
||||
|
||||
always:
|
||||
- name: cleanup venv and install directory
|
||||
file:
|
||||
path: '{{ galaxy_dir }}/ansible_collections'
|
||||
state: absent
|
||||
loop:
|
||||
- '{{ galaxy_dir }}/ansible_collections'
|
||||
- '{{ venv_dest }}'
|
Loading…
Reference in New Issue