ansible-galaxy - fix fallback for AH searches (#70957)
This commit is contained in:
parent
7f0c84ea15
commit
b1cb2553af
3 changed files with 31 additions and 5 deletions
2
changelogs/fragments/galaxy-collection-fallback.yml
Normal file
2
changelogs/fragments/galaxy-collection-fallback.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- ansible-galaxy collection install - fix fallback mechanism if the AH server did not have the collection requested - https://github.com/ansible/ansible/issues/70940
|
|
@ -525,12 +525,18 @@ class CollectionRequirement:
|
||||||
else:
|
else:
|
||||||
versions = api.get_collection_versions(namespace, name)
|
versions = api.get_collection_versions(namespace, name)
|
||||||
except GalaxyError as err:
|
except GalaxyError as err:
|
||||||
if err.http_code == 404:
|
if err.http_code != 404:
|
||||||
display.vvv("Collection '%s' is not available from server %s %s"
|
|
||||||
% (collection, api.name, api.api_server))
|
|
||||||
continue
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
versions = []
|
||||||
|
|
||||||
|
# Automation Hub doesn't return a 404 but an empty version list so we check that to align both AH and
|
||||||
|
# Galaxy when the collection is not available on that server.
|
||||||
|
if not versions:
|
||||||
|
display.vvv("Collection '%s' is not available from server %s %s" % (collection, api.name,
|
||||||
|
api.api_server))
|
||||||
|
continue
|
||||||
|
|
||||||
display.vvv("Collection '%s' obtained from server %s %s" % (collection, api.name, api.api_server))
|
display.vvv("Collection '%s' obtained from server %s %s" % (collection, api.name, api.api_server))
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -104,6 +104,24 @@
|
||||||
server: '{{ pulp_v3_server }}'
|
server: '{{ pulp_v3_server }}'
|
||||||
v3: true
|
v3: true
|
||||||
|
|
||||||
|
# fake.fake does not exist but we check the output to ensure it checked all 3
|
||||||
|
# servers defined in the config. We hardcode to -vvv as that's what level the
|
||||||
|
# message is shown
|
||||||
|
- name: test install fallback on server list
|
||||||
|
command: ansible-galaxy collection install fake.fake -vvv
|
||||||
|
ignore_errors: yes
|
||||||
|
environment:
|
||||||
|
ANSIBLE_CONFIG: '{{ galaxy_dir }}/ansible.cfg'
|
||||||
|
register: missing_fallback
|
||||||
|
|
||||||
|
- name: assert test install fallback on server list
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- missing_fallback.rc == 1
|
||||||
|
- '"Collection ''fake.fake'' is not available from server pulp_v2" in missing_fallback.stdout'
|
||||||
|
- '"Collection ''fake.fake'' is not available from server pulp_v3" in missing_fallback.stdout'
|
||||||
|
- '"Collection ''fake.fake'' is not available from server galaxy_ng" in missing_fallback.stdout'
|
||||||
|
|
||||||
- name: run ansible-galaxy collection download tests
|
- name: run ansible-galaxy collection download tests
|
||||||
include_tasks: download.yml
|
include_tasks: download.yml
|
||||||
args:
|
args:
|
||||||
|
|
Loading…
Reference in a new issue