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
This commit is contained in:
parent
91aea92c62
commit
1f1d6e5aec
2 changed files with 20 additions and 1 deletions
4
changelogs/fragments/70375-galaxy-server.yml
Normal file
4
changelogs/fragments/70375-galaxy-server.yml
Normal file
|
@ -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…
Reference in a new issue