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:
parent
680cade77a
commit
5a0621db55
1 changed files with 5 additions and 3 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue