iterate through task results only if the key is not at the root level (#18214)

Fixes https://github.com/ansible/ansible-modules-core/issues/5396
This commit is contained in:
jctanner 2016-10-27 09:43:49 -04:00 committed by GitHub
parent 680cade77a
commit 5a0621db55

View file

@ -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)