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`.

(cherry picked from commit 200d6bdb23)
This commit is contained in:
Andrew Haines 2016-11-18 16:28:53 +00:00 committed by Brian Coca
parent 0871d955fe
commit 35e198a616

View file

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