Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/ansible/executor/task_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def is_unreachable(self):
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)