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

now galaxy correctly detects empty requirements file

also allow for 'scm' and 'src' not to be populated in requirements entries
This commit is contained in:
Brian Coca 2015-10-20 14:38:07 -04:00
parent b46ce47a84
commit 1ecad5aed2
2 changed files with 20 additions and 10 deletions

View file

@ -310,7 +310,15 @@ class GalaxyCLI(CLI):
try:
f = open(role_file, 'r')
if role_file.endswith('.yaml') or role_file.endswith('.yml'):
for role in yaml.safe_load(f.read()):
try:
required_roles = yaml.safe_load(f.read())
except Exception as e:
raise AnsibleError("Unable to load data from the requirements file: %s" % role_file)
if required_roles is None:
raise AnsibleError("No roles found in file: %s" % role_file)
for role in required_roles:
role = RoleRequirement.role_yaml_parse(role)
self.display.debug('found role %s in yaml file' % str(role))
if 'name' not in role and 'scm' not in role:

View file

@ -140,6 +140,8 @@ class RoleRequirement(RoleDefinition):
role = RoleRequirement.role_spec_parse(role['role'])
else:
role = role.copy()
if 'src'in role:
# New style: { src: 'galaxy.role,version,name', other_vars: "here" }
if 'github.com' in role["src"] and 'http' in role["src"] and '+' not in role["src"] and not role["src"].endswith('.tar.gz'):
role["src"] = "git+" + role["src"]