Skip to content

Commit

Permalink
Clarify that index_var is 0 indexed (ansible#70548)
Browse files Browse the repository at this point in the history
A little further down the page is another index, ansible_loop.index, which shares a similar description but is 1 indexed.
Its zero indexed twin has a 0 suffix.

``ansible_loop.index``      The current iteration of the loop. (1 indexed)
``ansible_loop.index0``     The current iteration of the loop. (0 indexed)

To remove ambiguity around the usage of index_var, explicitly mention that this variable is 0 indexed.
  • Loading branch information
goetzk committed Jul 13, 2020
1 parent f4ea43c commit c410311
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/docsite/rst/user_guide/playbooks_loops.rst
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ To keep track of where you are in a loop, use the ``index_var`` directive with `
loop_control:
index_var: my_idx

.. note:: `index_var` is 0 indexed.

Defining inner and outer variable names with ``loop_var``
---------------------------------------------------------
.. versionadded:: 2.1
Expand Down

0 comments on commit c410311

Please sign in to comment.