From 4a5e52b2d2e59ba61144baaf93a33b1c44b0ae3f Mon Sep 17 00:00:00 2001 From: klshxsh <@klshxsh> Date: Fri, 9 Oct 2015 21:34:37 +0100 Subject: [PATCH 1/4] The serial keyword can be specified as a percentage, e.g '30%' or a number e.g. '3'; therefore it needs to be a string to allow both types --- lib/ansible/playbook/play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index 9d1959c1e58..a017ac4a719 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -87,7 +87,7 @@ class Play(Base, Taggable, Become): _any_errors_fatal = FieldAttribute(isa='bool', default=False, always_post_validate=True) _force_handlers = FieldAttribute(isa='bool', always_post_validate=True) _max_fail_percentage = FieldAttribute(isa='percent', always_post_validate=True) - _serial = FieldAttribute(isa='int', default=0, always_post_validate=True) + _serial = FieldAttribute(isa='string', default='0', always_post_validate=True) _strategy = FieldAttribute(isa='string', default='linear', always_post_validate=True) # ================================================================================= From ac00c9ced7f05c087f5465224e22eed8e6978d5e Mon Sep 17 00:00:00 2001 From: klshxsh Date: Mon, 12 Oct 2015 12:41:00 +0100 Subject: [PATCH 2/4] changed 'string' to 'percent' for _serial Note that this allows both integers (e.g. 3) and percentages (e.g. "30%") Also changed default back to 0 rather than '0' --- lib/ansible/playbook/play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index a017ac4a719..a24eb133ccf 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -87,7 +87,7 @@ class Play(Base, Taggable, Become): _any_errors_fatal = FieldAttribute(isa='bool', default=False, always_post_validate=True) _force_handlers = FieldAttribute(isa='bool', always_post_validate=True) _max_fail_percentage = FieldAttribute(isa='percent', always_post_validate=True) - _serial = FieldAttribute(isa='string', default='0', always_post_validate=True) + _serial = FieldAttribute(isa='percent', default=0, always_post_validate=True) _strategy = FieldAttribute(isa='string', default='linear', always_post_validate=True) # ================================================================================= From 63e288354e5674ef0adbb1c65c393892fb13a0ff Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 12 Oct 2015 09:00:27 -0400 Subject: [PATCH 3/4] Fix bug in way omitted values were set --- lib/ansible/playbook/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/playbook/base.py b/lib/ansible/playbook/base.py index 6e0e3b57389..6b6fdf3fae5 100644 --- a/lib/ansible/playbook/base.py +++ b/lib/ansible/playbook/base.py @@ -300,7 +300,7 @@ class Base: # if this evaluated to the omit value, set the value back to # the default specified in the FieldAttribute and move on if omit_value is not None and value == omit_value: - value = attribute.default + setattr(self, name, attribute.default) continue # and make sure the attribute is of the type it should be From 82e76e42e5366e470b05f27faa30339052ee2550 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Mon, 12 Oct 2015 09:00:43 -0400 Subject: [PATCH 4/4] Tweak to the way serial percentages are handled --- lib/ansible/executor/playbook_executor.py | 5 ++++- lib/ansible/playbook/play.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/ansible/executor/playbook_executor.py b/lib/ansible/executor/playbook_executor.py index 9f295cbe1ef..0b3d7f0db71 100644 --- a/lib/ansible/executor/playbook_executor.py +++ b/lib/ansible/executor/playbook_executor.py @@ -227,7 +227,10 @@ class PlaybookExecutor: serial_pct = int(play.serial.replace("%","")) serial = int((serial_pct/100.0) * len(all_hosts)) else: - serial = int(play.serial) + if play.serial is None: + serial = -1 + else: + serial = int(play.serial) # if the serial count was not specified or is invalid, default to # a list of all hosts, otherwise split the list of hosts into chunks diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index a24eb133ccf..f6ae213a5c4 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -87,7 +87,7 @@ class Play(Base, Taggable, Become): _any_errors_fatal = FieldAttribute(isa='bool', default=False, always_post_validate=True) _force_handlers = FieldAttribute(isa='bool', always_post_validate=True) _max_fail_percentage = FieldAttribute(isa='percent', always_post_validate=True) - _serial = FieldAttribute(isa='percent', default=0, always_post_validate=True) + _serial = FieldAttribute(isa='string', always_post_validate=True) _strategy = FieldAttribute(isa='string', default='linear', always_post_validate=True) # =================================================================================