From 31dc5342f31a24b7e485f92b37c8e42623e19d8c Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Wed, 30 Aug 2017 16:57:40 -0400 Subject: [PATCH] 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 --- lib/ansible/cli/galaxy.py | 45 +++++++++++++++++++++------------------ 1 file 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) + 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 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'])) - 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)