From a89412ecb13e4207a25aaf2ea6bd2c932463720f Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Tue, 29 Sep 2015 14:53:50 -0400 Subject: [PATCH] Fail all hosts if a run_once task fails Fixes #12563 --- lib/ansible/plugins/strategy/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 39d68f8e501..8067d25b46c 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -180,7 +180,11 @@ class StrategyBase: if result[0] == 'host_task_failed' or task_result.is_failed(): if not task.ignore_errors: self._display.debug("marking %s as failed" % host.name) - iterator.mark_host_failed(host) + if task.run_once: + # if we're using run_once, we have to fail every host here + [iterator.mark_host_failed(h) for h in self._inventory.get_hosts(iterator._play.hosts) if h.name not in self._tqm._unreachable_hosts] + else: + iterator.mark_host_failed(host) self._tqm._failed_hosts[host.name] = True self._tqm._stats.increment('failures', host.name) else: