summaryrefslogtreecommitdiff
path: root/lib/ansible/executor/task_result.py
diff options
context:
space:
mode:
authorMatt Martz <matt@sivel.net>2018-01-09 13:50:07 -0600
committerGitHub <noreply@github.com>2018-01-09 13:50:07 -0600
commitd1846425db087656b163069dc28982e44243f57d (patch)
treeb886334190a8ac8a327f4fd8eace7ad33f5f27e2 /lib/ansible/executor/task_result.py
parente802b769e6306c090a6a7f58c232aa855196a1be (diff)
downloadansible-d1846425db087656b163069dc28982e44243f57d.tar.gz
Provide a way to explicitly invoke the debugger (#34006)
* Provide a way to explicitly invoke the debugger with in the debug strategy * Merge the debugger strategy into StrategyBase * Fix some logic, pin to a single result * Make redo also continue * Make sure that if the debug closure doesn't need to process the result, that we still return it * Fix failing tests for the strategy * Clean up messages from debugger and exit code to match bin/ansible * Move the FieldAttribute higher, to apply at different levels * make debugger a string, expand logic * Better host state rollbacks * More explicit debugger prompt * ENABLE_TASK_DEBUGGER should be boolean, and better docs * No bare except, add pprint, alias h, vars to task_vars * _validate_debugger can ignore non-string, that can be caught later * Address issue if there were no previous tasks/state, and use the correct key * Update docs for changes to the debugger * Guard against a stat going negative through use of decrement * Add a few notes about using the debugger on the free strategy * Add changelog entry for task debugger * Add a few versionadded indicators and a note about vars -> task_vars
Diffstat (limited to 'lib/ansible/executor/task_result.py')
-rw-r--r--lib/ansible/executor/task_result.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/ansible/executor/task_result.py b/lib/ansible/executor/task_result.py
index 4abfa45c73..40a492d7d8 100644
--- a/lib/ansible/executor/task_result.py
+++ b/lib/ansible/executor/task_result.py
@@ -64,6 +64,26 @@ class TaskResult:
def is_unreachable(self):
return self._check_key('unreachable')
+ def needs_debugger(self, globally_enabled=False):
+ _debugger = self._task_fields.get('debugger')
+
+ ret = False
+ if globally_enabled and (self.is_failed() 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():
+ ret = True
+ elif _debugger in ('on_unreachable',) and self.is_unreachable():
+ ret = True
+ elif _debugger in('on_skipped',) and self.is_skipped():
+ ret = True
+
+ return ret
+
def _check_key(self, key):
'''get a specific key from the result or its items'''