mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
This commit is contained in:
parent
e7afd3d378
commit
079318bf4a
2 changed files with 16 additions and 2 deletions
|
@ -1015,6 +1015,18 @@ ENABLE_TASK_DEBUGGER:
|
||||||
ini:
|
ini:
|
||||||
- {key: enable_task_debugger, section: defaults}
|
- {key: enable_task_debugger, section: defaults}
|
||||||
version_added: "2.5"
|
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:
|
DEFAULT_STRATEGY:
|
||||||
name: Implied strategy
|
name: Implied strategy
|
||||||
default: 'linear'
|
default: 'linear'
|
||||||
|
|
|
@ -7,6 +7,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
from ansible import constants as C
|
||||||
from ansible.parsing.dataloader import DataLoader
|
from ansible.parsing.dataloader import DataLoader
|
||||||
from ansible.vars.clean import strip_internal_keys
|
from ansible.vars.clean import strip_internal_keys
|
||||||
|
|
||||||
|
@ -66,16 +67,17 @@ class TaskResult:
|
||||||
|
|
||||||
def needs_debugger(self, globally_enabled=False):
|
def needs_debugger(self, globally_enabled=False):
|
||||||
_debugger = self._task_fields.get('debugger')
|
_debugger = self._task_fields.get('debugger')
|
||||||
|
_ignore_errors = C.TASK_DEBUGGER_IGNORE_ERRORS and self._task_fields.get('ignore_errors')
|
||||||
|
|
||||||
ret = False
|
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
|
ret = True
|
||||||
|
|
||||||
if _debugger in ('always',):
|
if _debugger in ('always',):
|
||||||
ret = True
|
ret = True
|
||||||
elif _debugger in ('never',):
|
elif _debugger in ('never',):
|
||||||
ret = False
|
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
|
ret = True
|
||||||
elif _debugger in ('on_unreachable',) and self.is_unreachable():
|
elif _debugger in ('on_unreachable',) and self.is_unreachable():
|
||||||
ret = True
|
ret = True
|
||||||
|
|
Loading…
Reference in a new issue