Use the first galaxy server supporting v1 for roles (#70375)

* Use the first galaxy server supporting v1 for roles. Fixes #65440

* Add changelog fragment

* This is best effort, fall back to original behavior if something bad happens
pull/70431/head
Matt Martz 4 years ago committed by GitHub
parent 91aea92c62
commit 1f1d6e5aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,4 @@
bugfixes:
- ansible-galaxy - Instead of assuming the first defined server is galaxy,
filter based on the servers that support the v1 API, and return the first
of those (https://github.com/ansible/ansible/issues/65440)

@ -114,6 +114,7 @@ class GalaxyCLI(CLI):
self.api_servers = []
self.galaxy = None
self._api = None
super(GalaxyCLI, self).__init__(args)
def init_parser(self):
@ -499,7 +500,21 @@ class GalaxyCLI(CLI):
@property
def api(self):
return self.api_servers[0]
if self._api:
return self._api
for server in self.api_servers:
try:
if u'v1' in server.available_api_versions:
self._api = server
break
except Exception:
continue
if not self._api:
self._api = self.api_servers[0]
return self._api
def _get_default_collection_path(self):
return C.COLLECTIONS_PATHS[0]

Loading…
Cancel
Save