mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-09 23:00:02 -07:00
parent
3937082892
commit
7a81d5f11e
1 changed files with 0 additions and 27 deletions
|
@ -301,33 +301,6 @@ If you need to keep track of where you are in a loop, you can use the ``index_va
|
||||||
loop_control:
|
loop_control:
|
||||||
index_var: my_idx
|
index_var: my_idx
|
||||||
|
|
||||||
.. _loops_and_includes_2.0:
|
|
||||||
|
|
||||||
Loops and Includes in 2.0
|
|
||||||
`````````````````````````
|
|
||||||
|
|
||||||
Because ``loop_control`` is not available in Ansible 2.0, when using an include with a loop you should use ``set_fact`` to save the "outer" loops value
|
|
||||||
for ``item``::
|
|
||||||
|
|
||||||
# main.yml
|
|
||||||
- include_tasks: inner.yml
|
|
||||||
loop:
|
|
||||||
- 1
|
|
||||||
- 2
|
|
||||||
- 3
|
|
||||||
|
|
||||||
# inner.yml
|
|
||||||
- set_fact:
|
|
||||||
outer_item: "{{ item }}"
|
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: "outer item={{ outer_item }} inner item={{ item }}"
|
|
||||||
loop:
|
|
||||||
- a
|
|
||||||
- b
|
|
||||||
- c
|
|
||||||
|
|
||||||
.. note:: `include` is deprecated, you should be using `include_tasks`, `import_tasks`, `import_play` instead.
|
|
||||||
|
|
||||||
.. seealso::
|
.. seealso::
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue