mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-08 03:33:10 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user