From 35e198a61671a44a41090f034b0a8c784b56d0ca Mon Sep 17 00:00:00 2001 From: Andrew Haines Date: Fri, 18 Nov 2016 16:28:53 +0000 Subject: [PATCH] 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 200d6bdb2311a4df48d4665c9ca2908f5d34d5c1) --- lib/ansible/plugins/strategy/linear.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index c592824a057..6a4fe42543a 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -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 ]