1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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
This commit is contained in:
Sam Doran 2017-08-30 16:57:40 -04:00 committed by Brian Coca
parent f31696f77f
commit 31dc5342f3

View file

@ -397,28 +397,31 @@ class GalaxyCLI(CLI):
# install dependencies, if we want them # install dependencies, if we want them
if not no_deps and installed: if not no_deps and installed:
role_dependencies = role.metadata.get('dependencies') or [] if not role.metadata:
for dep in role_dependencies: display.warning("Meta file %s is empty. Skipping dependencies." % role.path)
display.debug('Installing dep %s' % dep) else:
dep_req = RoleRequirement() role_dependencies = role.metadata.get('dependencies') or []
dep_info = dep_req.role_yaml_parse(dep) for dep in role_dependencies:
dep_role = GalaxyRole(self.galaxy, **dep_info) display.debug('Installing dep %s' % dep)
if '.' not in dep_role.name and '.' not in dep_role.src and dep_role.scm is None: dep_req = RoleRequirement()
# we know we can skip this, as it's not going to dep_info = dep_req.role_yaml_parse(dep)
# be found on galaxy.ansible.com dep_role = GalaxyRole(self.galaxy, **dep_info)
continue if '.' not in dep_role.name and '.' not in dep_role.src and dep_role.scm is None:
if dep_role.install_info is None: # we know we can skip this, as it's not going to
if dep_role not in roles_left: # be found on galaxy.ansible.com
display.display('- adding dependency: %s' % str(dep_role)) continue
roles_left.append(dep_role) 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: else:
display.display('- dependency %s already pending installation.' % dep_role.name) if dep_role.install_info['version'] != dep_role.version:
else: display.warning('- dependency %s from role %s differs from already installed version (%s), skipping' %
if dep_role.install_info['version'] != dep_role.version: (str(dep_role), role.name, dep_role.install_info['version']))
display.warning('- dependency %s from role %s differs from already installed version (%s), skipping' % else:
(str(dep_role), role.name, dep_role.install_info['version'])) display.display('- dependency %s is already installed, skipping.' % dep_role.name)
else:
display.display('- dependency %s is already installed, skipping.' % dep_role.name)
if not installed: if not installed:
display.warning("- %s was NOT installed successfully." % role.name) display.warning("- %s was NOT installed successfully." % role.name)