fixed non ignore errors path to actually interrupt

fixed cases where missing/inaccessible file gave exception, now you get nice error
pull/11791/head
Brian Coca 9 years ago
parent 8153c34abf
commit 0e77871426

@ -154,8 +154,7 @@ class GalaxyCLI(CLI):
option --ignore-errors was specified option --ignore-errors was specified
""" """
if not self.get_opt("ignore_errors", False): if not self.get_opt("ignore_errors", False):
self.display.error('- you can use --ignore-errors to skip failed roles and finish processing the list.') raise AnsibleError('- you can use --ignore-errors to skip failed roles and finish processing the list.')
return rc
def execute_init(self): def execute_init(self):
""" """
@ -321,20 +320,24 @@ class GalaxyCLI(CLI):
roles_done = [] roles_done = []
roles_left = [] roles_left = []
if role_file: if role_file:
f = open(role_file, 'r') try:
if role_file.endswith('.yaml') or role_file.endswith('.yml'): f = open(role_file, 'r')
try: if role_file.endswith('.yaml') or role_file.endswith('.yml'):
rolesparsed = map(self.parse_requirements_files, yaml.safe_load(f)) try:
except: rolesparsed = map(self.parse_requirements_files, yaml.safe_load(f))
raise AnsibleError("%s does not seem like a valid yaml file" % role_file) except Exception as e:
roles_left = [GalaxyRole(self.galaxy, **r) for r in rolesparsed] raise AnsibleError("%s does not seem like a valid yaml file: %s" % (role_file, str(e)))
else: roles_left = [GalaxyRole(self.galaxy, **r) for r in rolesparsed]
# roles listed in a file, one per line else:
for rname in f.readlines(): # roles listed in a file, one per line
if rname.startswith("#") or rname.strip() == '': self.display.deprecated("Non yaml files for role requirements")
continue for rname in f.readlines():
roles_left.append(GalaxyRole(self.galaxy, rname.strip())) if rname.startswith("#") or rname.strip() == '':
f.close() continue
roles_left.append(GalaxyRole(self.galaxy, rname.strip()))
f.close()
except (IOError,OSError) as e:
raise AnsibleError("Unable to read requirements file (%s): %s" % (role_file, str(e)))
else: else:
# roles were specified directly, so we'll just go out grab them # roles were specified directly, so we'll just go out grab them
# (and their dependencies, unless the user doesn't want us to). # (and their dependencies, unless the user doesn't want us to).

@ -179,6 +179,7 @@ class Connection(ConnectionBase):
key_filename=key_filename, key_filename=key_filename,
password=self._play_context.password, password=self._play_context.password,
timeout=self._play_context.timeout, timeout=self._play_context.timeout,
compress=True,
port=port, port=port,
) )
except Exception as e: except Exception as e:

Loading…
Cancel
Save