diff --git a/lib/ansible/executor/task_executor.py b/lib/ansible/executor/task_executor.py index eee728bf5c..5e0f34599a 100644 --- a/lib/ansible/executor/task_executor.py +++ b/lib/ansible/executor/task_executor.py @@ -254,10 +254,10 @@ class TaskExecutor: label = None loop_pause = 0 if self._task.loop_control: - # the value may be 'None', so we still need to default it back to 'item' - loop_var = self._task.loop_control.loop_var or 'item' + loop_var = self._task.loop_control.loop_var + loop_pause = self._task.loop_control.pause + # the these may be 'None', so we still need to default to something useful label = self._task.loop_control.label or ('{{' + loop_var + '}}') - loop_pause = self._task.loop_control.pause or 0 if loop_var in task_vars: display.warning(u"The loop variable '%s' is already in use. " diff --git a/lib/ansible/playbook/included_file.py b/lib/ansible/playbook/included_file.py index ed2205f3f5..68f4712538 100644 --- a/lib/ansible/playbook/included_file.py +++ b/lib/ansible/playbook/included_file.py @@ -85,7 +85,7 @@ class IncludedFile: include_variables = include_result.get('include_variables', dict()) loop_var = 'item' if original_task.loop_control: - loop_var = original_task.loop_control.loop_var or 'item' + loop_var = original_task.loop_control.loop_var if loop_var in include_result: task_vars[loop_var] = include_variables[loop_var] = include_result[loop_var] diff --git a/lib/ansible/playbook/loop_control.py b/lib/ansible/playbook/loop_control.py index b983ee88ed..7fe0ca50ab 100644 --- a/lib/ansible/playbook/loop_control.py +++ b/lib/ansible/playbook/loop_control.py @@ -25,9 +25,9 @@ from ansible.playbook.base import Base class LoopControl(Base): - _loop_var = FieldAttribute(isa='str') + _loop_var = FieldAttribute(isa='str', default='item') _label = FieldAttribute(isa='str') - _pause = FieldAttribute(isa='int') + _pause = FieldAttribute(isa='int', default=0) def __init__(self): super(LoopControl, self).__init__() diff --git a/lib/ansible/plugins/strategy/__init__.py b/lib/ansible/plugins/strategy/__init__.py index 6a9428ddfd..426e51aae0 100644 --- a/lib/ansible/plugins/strategy/__init__.py +++ b/lib/ansible/plugins/strategy/__init__.py @@ -358,7 +358,7 @@ class StrategyBase: # get the correct loop var for use later if original_task.loop_control: - loop_var = original_task.loop_control.loop_var or 'item' + loop_var = original_task.loop_control.loop_var else: loop_var = 'item'