mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Add support for defining index var for task loops
This commit is contained in:
committed by
Brian Coca
parent
7be8079bad
commit
e9b0a4ccb4
@@ -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:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user