summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Roy <vincentroy8@gmail.com>2016-04-13 15:12:54 -0300
committerJames Cammarata <jimi@sngx.net>2016-05-18 08:17:53 -0400
commit46e9e4c4da7b684ae289bbf5f7f8b85c9ae750b8 (patch)
treea7393d13956f01dffdc3062d513f5caf26b20ea0
parent9602e439525e5e14b1e062e18bbdee3b47af8248 (diff)
downloadansible-46e9e4c4da7b684ae289bbf5f7f8b85c9ae750b8.tar.gz
Handle max_fail_percentage per task.
-rw-r--r--lib/ansible/plugins/strategy/linear.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py
index c386df7fe1..871642daff 100644
--- a/lib/ansible/plugins/strategy/linear.py
+++ b/lib/ansible/plugins/strategy/linear.py
@@ -363,6 +363,19 @@ class StrategyModule(StrategyBase):
iterator.mark_host_failed(host)
display.debug("done checking for any_errors_fatal")
+ display.debug("checking for max_fail_percentage")
+ if iterator._play.max_fail_percentage is not None and len(results) > 0:
+ percentage = iterator._play.max_fail_percentage / 100.0
+
+ if (len(failed_hosts) / len(results)) > percentage:
+ for host in hosts_left:
+ # don't double-mark hosts, or the iterator will potentially
+ # fail them out of the rescue/always states
+ if host.name not in failed_hosts:
+ self._tqm._failed_hosts[host.name] = True
+ iterator.mark_host_failed(host)
+ display.debug("done checking for max_fail_percentage")
+
except (IOError, EOFError) as e:
display.debug("got IOError/EOFError in task loop: %s" % e)
# most likely an abort, return failed