made galaxy more resilient with bad yaml files and comments/spaces in non yaml files

fixes #10641
This commit is contained in:
Brian Coca 2015-07-29 19:28:29 -04:00
parent 63b54a3271
commit e81ec32719

View file

@ -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: