diff options
author | Toshio Kuratomi <toshio@fedoraproject.org> | 2016-03-15 20:31:40 -0700 |
---|---|---|
committer | Toshio Kuratomi <toshio@fedoraproject.org> | 2016-03-15 20:31:40 -0700 |
commit | fe278202f2117b1822807969f94e32a54a5db761 (patch) | |
tree | 4a9fda438c0b20a1633f1cf71fe64fd603d53b1b | |
parent | 6b1b4e03b0d006a2d402d6455c51a3e2da7996bf (diff) | |
download | ansible-fe278202f2117b1822807969f94e32a54a5db761.tar.gz |
Fix saving of tracebacks on module failure
-rw-r--r-- | lib/ansible/plugins/action/__init__.py | 13 | ||||
-rw-r--r-- | lib/ansible/plugins/action/synchronize.py | 2 |
2 files changed, 7 insertions, 8 deletions
diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 917e16dec3..392b670406 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -506,13 +506,12 @@ class ActionBase(with_metaclass(ABCMeta, object)): except ValueError: # not valid json, lets try to capture error data = dict(failed=True, parsed=False) - if 'stderr' in res and res['stderr'].startswith(u'Traceback'): - data['exception'] = res['stderr'] - else: - data['msg'] = "MODULE FAILURE" - data['module_stdout'] = res.get('stdout', u'') - if 'stderr' in res: - data['module_stderr'] = res['stderr'] + data['msg'] = "MODULE FAILURE" + data['module_stdout'] = res.get('stdout', u'') + if 'stderr' in res: + data['module_stderr'] = res['stderr'] + if res['stderr'].startswith(u'Traceback'): + data['exception'] = res['stderr'] # pre-split stdout into lines, if stdout is in the data and there # isn't already a stdout_lines value there diff --git a/lib/ansible/plugins/action/synchronize.py b/lib/ansible/plugins/action/synchronize.py index 9b267844b8..c0845d97f2 100644 --- a/lib/ansible/plugins/action/synchronize.py +++ b/lib/ansible/plugins/action/synchronize.py @@ -327,6 +327,6 @@ class ActionModule(ActionBase): if 'SyntaxError' in result.get('exception', result.get('msg', '')): # Emit a warning about using python3 because synchronize is # 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' return result |