From c3c398cffe202146df9c73b8ed6e478c054dd207 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Wed, 17 Jun 2015 15:38:52 -0400 Subject: [PATCH] Cleaning up some task failure detection problems * fixed a bug in which failures from a with_* loop were not being caught correctly, leading to tasks continuing when they should stop * when ignore_errors is enabled, the failure will no longer count towards the number of failed tasks --- lib/ansible/executor/task_result.py | 3 ++- lib/ansible/plugins/strategies/__init__.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/executor/task_result.py b/lib/ansible/executor/task_result.py index 2b760bac003..99ac06c8eb3 100644 --- a/lib/ansible/executor/task_result.py +++ b/lib/ansible/executor/task_result.py @@ -43,7 +43,7 @@ class TaskResult: return self._check_key('skipped') def is_failed(self): - if 'failed_when_result' in self._result: + if 'results' in self._result and True in [True for x in self._result['results'] if 'failed_when_result' in x]: return self._check_key('failed_when_result') else: return self._check_key('failed') or self._result.get('rc', 0) != 0 @@ -57,5 +57,6 @@ class TaskResult: for res in self._result.get('results', []): if isinstance(res, dict): flag |= res.get(key, False) + return flag else: return self._result.get(key, False) diff --git a/lib/ansible/plugins/strategies/__init__.py b/lib/ansible/plugins/strategies/__init__.py index 57630f4f21e..e9cdd7d35ce 100644 --- a/lib/ansible/plugins/strategies/__init__.py +++ b/lib/ansible/plugins/strategies/__init__.py @@ -154,7 +154,9 @@ class StrategyBase: debug("marking %s as failed" % host.name) iterator.mark_host_failed(host) self._tqm._failed_hosts[host.name] = True - self._tqm._stats.increment('failures', host.name) + self._tqm._stats.increment('failures', host.name) + else: + self._tqm._stats.increment('ok', host.name) self._tqm.send_callback('v2_runner_on_failed', task_result) elif result[0] == 'host_unreachable': self._tqm._unreachable_hosts[host.name] = True