mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Fix for serial when percent amount is less than one host (#15396)
Ansible when there was a percentage that was calculated to be less than 1.0 would run all hosts as the value for a rolling update. The error is due to the fact that Python will round a float that is under 1.0 to 0, which will trigger the case of 0 hosts. The 0 host case tells ansible to run all hosts. The fix will see if the percentage calculation after int conversion is 0 and will else to 1 host.
This commit is contained in:
committed by
Brian Coca
parent
22467a0de8
commit
7bee994e1c
@@ -214,7 +214,7 @@ class PlaybookExecutor:
|
||||
# and convert it to an integer value based on the number of hosts
|
||||
if isinstance(play.serial, string_types) and play.serial.endswith('%'):
|
||||
serial_pct = int(play.serial.replace("%",""))
|
||||
serial = int((serial_pct/100.0) * len(all_hosts))
|
||||
serial = int((serial_pct/100.0) * len(all_hosts)) or 1
|
||||
else:
|
||||
if play.serial is None:
|
||||
serial = -1
|
||||
|
||||
Reference in New Issue
Block a user