summaryrefslogtreecommitdiff
path: root/lib/ansible
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2017-08-30 16:57:40 -0400
committerBrian Coca <bcoca@users.noreply.github.com>2017-08-31 13:50:01 -0400
commit31dc5342f31a24b7e485f92b37c8e42623e19d8c (patch)
tree262e0bf7bd9cde2adcee47a9df112c193c94c247 /lib/ansible
parentf31696f77fc248d06f4fd5f3f7ca875b87aec81d (diff)
downloadansible-31dc5342f31a24b7e485f92b37c8e42623e19d8c.tar.gz
Do not try to process an empty metai/main.yml file
If an empty meta/main.yml file exists, ansible-galaxy threw an unhelpful exception. Now, a warning message is printed and the installation does not fail. See https://stackoverflow.com/questions/45432994/ansible-galaxy-fails-on-dependency-with-empty-meta-main-yml
Diffstat (limited to 'lib/ansible')
-rw-r--r--lib/ansible/cli/galaxy.py45
1 files changed, 24 insertions, 21 deletions
diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py
index fc42e90fd1..81ff613280 100644
--- a/lib/ansible/cli/galaxy.py
+++ b/lib/ansible/cli/galaxy.py
@@ -397,28 +397,31 @@ class GalaxyCLI(CLI):
# install dependencies, if we want them
if not no_deps and installed:
- role_dependencies = role.metadata.get('dependencies') or []
- for dep in role_dependencies:
- display.debug('Installing dep %s' % dep)
- dep_req = RoleRequirement()
- dep_info = dep_req.role_yaml_parse(dep)
- dep_role = GalaxyRole(self.galaxy, **dep_info)
- if '.' not in dep_role.name and '.' not in dep_role.src and dep_role.scm is None:
- # we know we can skip this, as it's not going to
- # be found on galaxy.ansible.com
- continue
- if dep_role.install_info is None:
- if dep_role not in roles_left:
- display.display('- adding dependency: %s' % str(dep_role))
- roles_left.append(dep_role)
- else:
- display.display('- dependency %s already pending installation.' % dep_role.name)
- else:
- if dep_role.install_info['version'] != dep_role.version:
- display.warning('- dependency %s from role %s differs from already installed version (%s), skipping' %
- (str(dep_role), role.name, dep_role.install_info['version']))
+ if not role.metadata:
+ display.warning("Meta file %s is empty. Skipping dependencies." % role.path)
+ else:
+ role_dependencies = role.metadata.get('dependencies') or []
+ for dep in role_dependencies:
+ display.debug('Installing dep %s' % dep)
+ dep_req = RoleRequirement()
+ dep_info = dep_req.role_yaml_parse(dep)
+ dep_role = GalaxyRole(self.galaxy, **dep_info)
+ if '.' not in dep_role.name and '.' not in dep_role.src and dep_role.scm is None:
+ # we know we can skip this, as it's not going to
+ # be found on galaxy.ansible.com
+ continue
+ if dep_role.install_info is None:
+ if dep_role not in roles_left:
+ display.display('- adding dependency: %s' % str(dep_role))
+ roles_left.append(dep_role)
+ else:
+ display.display('- dependency %s already pending installation.' % dep_role.name)
else:
- display.display('- dependency %s is already installed, skipping.' % dep_role.name)
+ if dep_role.install_info['version'] != dep_role.version:
+ display.warning('- dependency %s from role %s differs from already installed version (%s), skipping' %
+ (str(dep_role), role.name, dep_role.install_info['version']))
+ else:
+ display.display('- dependency %s is already installed, skipping.' % dep_role.name)
if not installed:
display.warning("- %s was NOT installed successfully." % role.name)