diff --git a/lib/ansible/executor/task_result.py b/lib/ansible/executor/task_result.py index 8d0b3ffa34e..f62d430bf1c 100644 --- a/lib/ansible/executor/task_result.py +++ b/lib/ansible/executor/task_result.py @@ -67,7 +67,7 @@ class TaskResult: '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 + return self._check_key('failed') def is_unreachable(self): return self._check_key('unreachable') diff --git a/test/units/executor/test_task_result.py b/test/units/executor/test_task_result.py index cd31f3794e9..74717b73d57 100644 --- a/test/units/executor/test_task_result.py +++ b/test/units/executor/test_task_result.py @@ -125,11 +125,11 @@ class TestTaskResult(unittest.TestCase): tr = TaskResult(mock_host, mock_task, dict()) self.assertFalse(tr.is_failed()) - # test failed result with rc values + # test failed result with rc values (should not matter) tr = TaskResult(mock_host, mock_task, dict(rc=0)) self.assertFalse(tr.is_failed()) tr = TaskResult(mock_host, mock_task, dict(rc=1)) - self.assertTrue(tr.is_failed()) + self.assertFalse(tr.is_failed()) # test with failed in result tr = TaskResult(mock_host, mock_task, dict(failed=True))