From 245ce9461d376ac1f9d508308e8525b761d93a2b Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 12 Jul 2016 03:01:47 -0500 Subject: [PATCH] Fix unreachable host/any_errors_fatal bug in linear strategy 2e003adb added the ability for tasks using any_errors_fatal to fail when there were unreachable hosts. However that patch used the running unreachable hosts data rather than the results from the current task, which causes failures when any run_once or BYPASS_HOST_LOOP task is hit after an unreachable host causes a failure. This patch corrects that by using the current set of results to determine if any hosts were unreachable during the last task only. Fixes ansible/ansible-modules-core#4160 --- lib/ansible/plugins/strategy/linear.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index b0ba34cae1a..50028fbe1c4 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -349,12 +349,15 @@ class StrategyModule(StrategyBase): display.debug("checking for any_errors_fatal") failed_hosts = [] + unreachable_hosts = [] for res in results: if res.is_failed(): failed_hosts.append(res._host.name) + elif res.is_unreachable(): + unreachable_hosts.append(res._host.name) # if any_errors_fatal and we had an error, mark all hosts as failed - if any_errors_fatal and (len(failed_hosts) > 0 or len(self._tqm._unreachable_hosts.keys()) > 0): + if any_errors_fatal and (len(failed_hosts) > 0 or len(unreachable_hosts) > 0): for host in hosts_left: # don't double-mark hosts, or the iterator will potentially # fail them out of the rescue/always states