From 59f96d713e7ca9994403409d021b891609ce4906 Mon Sep 17 00:00:00 2001 From: Will Thames Date: Thu, 6 Aug 2015 11:59:47 +1000 Subject: [PATCH] Allow exceptions to pass through the program This is useful when using `ipython --pdb -- $(which ansible-playbook) ...` for debugging. Also show traceback when `ANSIBLE_DEBUG` is on --- bin/ansible | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/ansible b/bin/ansible index 209b235c88d..04ec345058c 100755 --- a/bin/ansible +++ b/bin/ansible @@ -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 @@ -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)