Skip to content

Commit

Permalink
Allow for no role_versions to be present
Browse files Browse the repository at this point in the history
  fixes #46650

  better info on fetch, ensure list return
  • Loading branch information
bcoca committed May 16, 2019
1 parent a4f0861 commit dc95f7c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/dont_assume_role_versions.yml
@@ -0,0 +1,2 @@
bugfixes:
- new code assumed role_versions always were present event though rest of code does not.
7 changes: 4 additions & 3 deletions lib/ansible/galaxy/api.py
Expand Up @@ -200,6 +200,7 @@ def fetch_role_related(self, related, role_id):
The url comes from the 'related' field of the role.
"""

results = []
try:
url = '%s/roles/%s/%s/?page_size=50' % (self.baseurl, role_id, related)
data = self.__call_galaxy(url)
Expand All @@ -210,9 +211,9 @@ def fetch_role_related(self, related, role_id):
data = self.__call_galaxy(url)
results += data['results']
done = (data.get('next_link', None) is None)
return results
except Exception:
return None
except Exception as e:
display.vvvv("Unable to retrive role (id=%s) data (%s), but this is not fatal so we continue: %s" % (role_id, related, to_native(e)))
return results

@g_connect
def get_list(self, what):
Expand Down
4 changes: 2 additions & 2 deletions lib/ansible/galaxy/role.py
Expand Up @@ -230,13 +230,13 @@ def install(self):
'Please contact the role author to resolve versioning conflicts, or specify an explicit role version to '
'install.' % ', '.join([v.vstring for v in loose_versions])
)
self.version = str(loose_versions[-1])
self.version = to_text(loose_versions[-1])
elif role_data.get('github_branch', None):
self.version = role_data['github_branch']
else:
self.version = 'master'
elif self.version != 'master':
if role_versions and str(self.version) not in [a.get('name', None) for a in role_versions]:
if role_versions and to_text(self.version) not in [a.get('name', None) for a in role_versions]:
raise AnsibleError("- the specified version (%s) of %s was not found in the list of available versions (%s)." % (self.version,
self.name,
role_versions))
Expand Down

0 comments on commit dc95f7c

Please sign in to comment.