diff --git a/lib/ansible/executor/task_result.py b/lib/ansible/executor/task_result.py index 0f1967fe5c..8de375a026 100644 --- a/lib/ansible/executor/task_result.py +++ b/lib/ansible/executor/task_result.py @@ -62,11 +62,13 @@ class TaskResult: return self._check_key('unreachable') def _check_key(self, key): - if self._result.get('results', []): + '''get a specific key from the result or it's items''' + + if isinstance(self._result, dict) and key in self._result: + return self._result.get(key, False) + else: flag = False 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)