Skip to content

Commit

Permalink
simpler loop_control defaults (ansible#34008)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoca authored and jborean93 committed Dec 20, 2017
1 parent 76590ab commit 8c6d823
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/ansible/executor/task_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ def _run_loop(self, items):
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. "
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/playbook/included_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_original_host(host):
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]

Expand Down
4 changes: 2 additions & 2 deletions lib/ansible/playbook/loop_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

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__()
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/plugins/strategy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def parent_handler_match(target_handler, handler_name):

# 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'

Expand Down

0 comments on commit 8c6d823

Please sign in to comment.