summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2018-01-11 17:41:23 -0600
committerMatt Martz <matt@sivel.net>2018-01-30 09:02:03 -0600
commit6fbb47f3c7dd62165ab2802c32ed611c2ea11b0c (patch)
tree333e61f3c7d46101a71fe8cd776ab71609e1806f
parentb08b4b720f3f25f85b9a463744f669d3af9db136 (diff)
downloadansible-6fbb47f3c7dd62165ab2802c32ed611c2ea11b0c.tar.gz
Catch exception comparing role versions, and provide a user friendly error message. Fixes #32301 (#34427)
(cherry picked from commit 42a0d7141339295cf7fd2f5ed05d7ec2ef5cb8c1)
-rw-r--r--lib/ansible/galaxy/role.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py
index f0800ba3d9..cb299a4905 100644
--- a/lib/ansible/galaxy/role.py
+++ b/lib/ansible/galaxy/role.py
@@ -233,7 +233,14 @@ class GalaxyRole(object):
# of the master branch
if len(role_versions) > 0:
loose_versions = [LooseVersion(a.get('name', None)) for a in role_versions]
- loose_versions.sort()
+ try:
+ loose_versions.sort()
+ except TypeError:
+ raise AnsibleError(
+ 'Unable to compare role versions (%s) to determine the most recent version due to incompatible version formats. '
+ '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])
elif role_data.get('github_branch', None):
self.version = role_data['github_branch']