Don't assume a task with non-dict loop results has been skipped.

This changeset addresses the issue reported here:

  ansible/ansible-modules-core#1765

The yum module (at least) includes its task results as strings, rather than
dicts, and the code this changeset replaces assumed that in that instance the
task was skipped. The updated behaviour assumes that the task has been
skipped only if:

* results exist, and
* all results are dicts that include a truthy skipped value
This commit is contained in:
Andrew Taumoefolau 2016-05-04 15:14:28 +10:00 committed by nitzmahone
parent 478674cc57
commit 85868e07a9

View file

@ -41,11 +41,8 @@ class TaskResult:
def is_skipped(self): def is_skipped(self):
if 'results' in self._result and self._task.loop: if 'results' in self._result and self._task.loop:
flag = True results = self._result['results']
for res in self._result.get('results', []): return results and all(isinstance(res, dict) and res.get('skipped', False) for res in results)
if isinstance(res, dict):
flag &= res.get('skipped', False)
return flag
else: else:
return self._result.get('skipped', False) return self._result.get('skipped', False)