Fix saving of tracebacks on module failure

pull/14988/head
Toshio Kuratomi 9 years ago
parent 6b1b4e03b0
commit fe278202f2

@ -506,13 +506,12 @@ class ActionBase(with_metaclass(ABCMeta, object)):
except ValueError: except ValueError:
# not valid json, lets try to capture error # not valid json, lets try to capture error
data = dict(failed=True, parsed=False) data = dict(failed=True, parsed=False)
if 'stderr' in res and res['stderr'].startswith(u'Traceback'): data['msg'] = "MODULE FAILURE"
data['exception'] = res['stderr'] data['module_stdout'] = res.get('stdout', u'')
else: if 'stderr' in res:
data['msg'] = "MODULE FAILURE" data['module_stderr'] = res['stderr']
data['module_stdout'] = res.get('stdout', u'') if res['stderr'].startswith(u'Traceback'):
if 'stderr' in res: data['exception'] = res['stderr']
data['module_stderr'] = res['stderr']
# pre-split stdout into lines, if stdout is in the data and there # pre-split stdout into lines, if stdout is in the data and there
# isn't already a stdout_lines value there # isn't already a stdout_lines value there

@ -327,6 +327,6 @@ class ActionModule(ActionBase):
if 'SyntaxError' in result.get('exception', result.get('msg', '')): if 'SyntaxError' in result.get('exception', result.get('msg', '')):
# Emit a warning about using python3 because synchronize is # Emit a warning about using python3 because synchronize is
# somewhat unique in running on localhost # somewhat unique in running on localhost
result['traceback'] = result['msg'] result['exception'] = result['msg']
result['msg'] = 'SyntaxError parsing module. Perhaps invoking "python" on your local (or delegate_to) machine invokes python3. You can set ansible_python_interpreter for localhost (or the delegate_to machine) to the location of python2 to fix this' result['msg'] = 'SyntaxError parsing module. Perhaps invoking "python" on your local (or delegate_to) machine invokes python3. You can set ansible_python_interpreter for localhost (or the delegate_to machine) to the location of python2 to fix this'
return result return result

Loading…
Cancel
Save