Skip to content

Commit

Permalink
auto tb on vvv+ or debug (ansible#26106)
Browse files Browse the repository at this point in the history
* auto tb on vvv+ or debug

* updated as per feedback
  • Loading branch information
bcoca authored Jun 28, 2017
1 parent 11836a0 commit d5f4c2a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ansible/module_utils/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2134,6 +2134,11 @@ def fail_json(self, **kwargs):
if 'changed' not in kwargs:
kwargs['changed'] = False

# add traceback if debug or high verbosity and it is missing
# Note: badly named as exception, it is really always been 'traceback'
if 'exception' not in kwargs and sys.exc_info()[2] and (self._debug or self._verbosity >= 3):
kwargs['exception'] = ''.join(traceback.format_tb(sys.exc_info()[2]))

self.do_cleanup_files()
self._return_formatted(kwargs)
sys.exit(1)
Expand Down

0 comments on commit d5f4c2a

Please sign in to comment.