Add support for defining index var for task loops

This commit is contained in:
Andrew Gaffney
2018-01-26 14:29:04 -07:00
committed by Brian Coca
parent 7be8079bad
commit e9b0a4ccb4
6 changed files with 58 additions and 1 deletions

View File

@@ -287,6 +287,19 @@ Another option to loop control is ``pause``, which allows you to control the tim
loop_control:
pause: 3
.. versionadded:: 2.7
If you need to keep track of where you are in a loop, you can use the ``index_var`` option to loop control to specify a variable name to contain the current loop index.::
- name: count our fruit
debug:
msg: "{{ item }} with index {{ my_idx }}"
loop:
- apple
- banana
- pear
loop_control:
index_var: my_idx
.. _loops_and_includes_2.0: