Honor ignore_errors when invoking the debugger, add config to disable this behavior (#39868)

* Honor ignore_errors when invoking the debugger, add config to disable this behavior. Fixes #39863

* Limit ignore_errors logic to failed
pull/40959/merge
Matt Martz 7 years ago committed by ansibot
parent e7afd3d378
commit 079318bf4a

@ -1015,6 +1015,18 @@ ENABLE_TASK_DEBUGGER:
ini:
- {key: enable_task_debugger, section: defaults}
version_added: "2.5"
TASK_DEBUGGER_IGNORE_ERRORS:
name: Whether a failed task with ignore_errors=True will still invoke the debugger
default: True
description:
- This option defines whether the task debugger will be invoked on a failed task when ignore_errors=True
is specified.
- True specifies that the debugger wil honor ignore_errors, False will not honor ignore_errors.
type: boolean
env: [{name: ANSIBLE_TASK_DEBUGGER_IGNORE_ERRORS}]
ini:
- {key: task_debugger_ignore_errors, section: defaults}
version_added: "2.7"
DEFAULT_STRATEGY:
name: Implied strategy
default: 'linear'

@ -7,6 +7,7 @@ __metaclass__ = type
from copy import deepcopy
from ansible import constants as C
from ansible.parsing.dataloader import DataLoader
from ansible.vars.clean import strip_internal_keys
@ -66,16 +67,17 @@ class TaskResult:
def needs_debugger(self, globally_enabled=False):
_debugger = self._task_fields.get('debugger')
_ignore_errors = C.TASK_DEBUGGER_IGNORE_ERRORS and self._task_fields.get('ignore_errors')
ret = False
if globally_enabled and (self.is_failed() or self.is_unreachable()):
if globally_enabled and ((self.is_failed() and not _ignore_errors) or self.is_unreachable()):
ret = True
if _debugger in ('always',):
ret = True
elif _debugger in ('never',):
ret = False
elif _debugger in ('on_failed',) and self.is_failed():
elif _debugger in ('on_failed',) and self.is_failed() and not _ignore_errors:
ret = True
elif _debugger in ('on_unreachable',) and self.is_unreachable():
ret = True

Loading…
Cancel
Save