mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
made galaxy more resilient with bad yaml files and comments/spaces in non yaml files
fixes #10641
This commit is contained in:
parent
63b54a3271
commit
e81ec32719
1 changed files with 6 additions and 1 deletions
|
@ -323,11 +323,16 @@ class GalaxyCLI(CLI):
|
|||
if role_file:
|
||||
f = open(role_file, 'r')
|
||||
if role_file.endswith('.yaml') or role_file.endswith('.yml'):
|
||||
try:
|
||||
rolesparsed = map(self.parse_requirements_files, yaml.safe_load(f))
|
||||
except:
|
||||
raise AnsibleError("%s does not seem like a valid yaml file" % role_file)
|
||||
roles_left = [GalaxyRole(self.galaxy, **r) for r in rolesparsed]
|
||||
else:
|
||||
# roles listed in a file, one per line
|
||||
for rname in f.readlines():
|
||||
if rname.startswith("#") or rname.strip() == '':
|
||||
continue
|
||||
roles_left.append(GalaxyRole(self.galaxy, rname.strip()))
|
||||
f.close()
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue