Skip to content

Commit

Permalink
Allow exceptions to pass through the program
Browse files Browse the repository at this point in the history
This is useful when using `ipython --pdb -- $(which ansible-playbook)
...` for debugging.

Also show traceback when `ANSIBLE_DEBUG` is on
  • Loading branch information
willthames committed Aug 6, 2015
1 parent e7b5cb8 commit 59f96d7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions bin/ansible
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import os
import sys
import traceback

import ansible.constants as C
from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError
from ansible.utils.display import Display

Expand Down Expand Up @@ -103,8 +104,11 @@ if __name__ == '__main__':
except Exception as e:
have_cli_options = cli is not None and cli.options is not None
display.error("Unexpected Exception: %s" % str(e), wrap_text=False)
if not have_cli_options or have_cli_options and cli.options.verbosity > 2:
if not have_cli_options or have_cli_options and cli.options.verbosity > 2 or C.DEFAULT_DEBUG:
display.display("the full traceback was:\n\n%s" % traceback.format_exc())
else:
display.display("to see the full traceback, use -vvv")
sys.exit(250)
if C.DEFAULT_DEBUG:
raise
else:
sys.exit(250)

0 comments on commit 59f96d7

Please sign in to comment.