1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fixes ansible/ansible#3609 Add max_fail_pct to playbook parameter, to complement serial option, So if total number of failures execeed max_fail_pct * total number of hosts, do not go to the next serial batch

This commit is contained in:
Kavin Kankeshwar 2013-07-23 16:03:13 -07:00 committed by James Cammarata
parent 2dd3f01513
commit 3f247fcbe3
2 changed files with 7 additions and 3 deletions

View file

@ -580,6 +580,10 @@ class PlayBook(object):
if task.any_errors_fatal and len(host_list) < hosts_count: if task.any_errors_fatal and len(host_list) < hosts_count:
host_list = None host_list = None
# If threshold for max nodes failed is exceeded , bail out.
if (hosts_count - len(host_list)) > int((play.max_fail_pct)/100.0 * hosts_count):
host_list = None
# if no hosts remain, drop out # if no hosts remain, drop out
if not host_list: if not host_list:
self.callbacks.on_no_hosts_remaining() self.callbacks.on_no_hosts_remaining()

View file

@ -32,7 +32,7 @@ class Play(object):
'handlers', 'remote_user', 'remote_port', 'handlers', 'remote_user', 'remote_port',
'sudo', 'sudo_user', 'transport', 'playbook', 'sudo', 'sudo_user', 'transport', 'playbook',
'tags', 'gather_facts', 'serial', '_ds', '_handlers', '_tasks', 'tags', 'gather_facts', 'serial', '_ds', '_handlers', '_tasks',
'basedir', 'any_errors_fatal', 'roles' 'basedir', 'any_errors_fatal', 'roles', 'max_fail_pct'
] ]
# to catch typos and so forth -- these are userland names # to catch typos and so forth -- these are userland names
@ -41,7 +41,7 @@ class Play(object):
'hosts', 'name', 'vars', 'vars_prompt', 'vars_files', 'hosts', 'name', 'vars', 'vars_prompt', 'vars_files',
'tasks', 'handlers', 'user', 'port', 'include', 'tasks', 'handlers', 'user', 'port', 'include',
'sudo', 'sudo_user', 'connection', 'tags', 'gather_facts', 'serial', 'sudo', 'sudo_user', 'connection', 'tags', 'gather_facts', 'serial',
'any_errors_fatal', 'roles', 'pre_tasks', 'post_tasks' 'any_errors_fatal', 'roles', 'pre_tasks', 'post_tasks', 'max_fail_pct'
] ]
# ************************************************* # *************************************************
@ -101,9 +101,9 @@ class Play(object):
self.sudo_user = ds.get('sudo_user', self.playbook.sudo_user) self.sudo_user = ds.get('sudo_user', self.playbook.sudo_user)
self.transport = ds.get('connection', self.playbook.transport) self.transport = ds.get('connection', self.playbook.transport)
self.gather_facts = ds.get('gather_facts', None) self.gather_facts = ds.get('gather_facts', None)
self.serial = int(ds.get('serial', 0))
self.remote_port = self.remote_port self.remote_port = self.remote_port
self.any_errors_fatal = ds.get('any_errors_fatal', False) self.any_errors_fatal = ds.get('any_errors_fatal', False)
self.max_fail_pct = int(ds.get('max_fail_pct', 100))
load_vars = {} load_vars = {}
if self.playbook.inventory.basedir() is not None: if self.playbook.inventory.basedir() is not None: