Default include_role results to empty list in linear strategy plugin

Fixes #18544.

When a loop is over an empty list, the result is set to

    {'skipped_reason': u'No items in the list', 'skipped': True, 'changed': False}

which means that accessing `hr._result['results']` throws a `KeyError`.
This commit is contained in:
Andrew Haines 2016-11-18 16:28:53 +00:00 committed by Brian Coca
parent aff5d9160a
commit 200d6bdb23

View file

@ -287,7 +287,7 @@ class StrategyModule(StrategyBase):
loop_var = 'item' loop_var = 'item'
if hr._task.loop_control: if hr._task.loop_control:
loop_var = hr._task.loop_control.loop_var or 'item' loop_var = hr._task.loop_control.loop_var or 'item'
include_results = hr._result['results'] include_results = hr._result.get('results', [])
else: else:
include_results = [ hr._result ] include_results = [ hr._result ]