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
(cherry picked from commit 5a0621db55
)
This commit is contained in:
parent
1ebc94f290
commit
95a8bbdbda
1 changed files with 5 additions and 3 deletions
|
@ -62,11 +62,13 @@ class TaskResult:
|
||||||
return self._check_key('unreachable')
|
return self._check_key('unreachable')
|
||||||
|
|
||||||
def _check_key(self, key):
|
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
|
flag = False
|
||||||
for res in self._result.get('results', []):
|
for res in self._result.get('results', []):
|
||||||
if isinstance(res, dict):
|
if isinstance(res, dict):
|
||||||
flag |= res.get(key, False)
|
flag |= res.get(key, False)
|
||||||
return flag
|
return flag
|
||||||
else:
|
|
||||||
return self._result.get(key, False)
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue