user_guide: Add an example for loop (#71441)
Explain how to use complex data in loop while converting from with_together Fixes: #47906 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
985ba187b2
commit
5c1594916a
1 changed files with 14 additions and 0 deletions
|
@ -97,6 +97,20 @@ with_together
|
||||||
msg: "{{ item.0 }} - {{ item.1 }}"
|
msg: "{{ item.0 }} - {{ item.1 }}"
|
||||||
loop: "{{ list_one|zip(list_two)|list }}"
|
loop: "{{ list_one|zip(list_two)|list }}"
|
||||||
|
|
||||||
|
Another example with complex data
|
||||||
|
|
||||||
|
.. code-block:: yaml+jinja
|
||||||
|
|
||||||
|
- name: with_together -> loop
|
||||||
|
debug:
|
||||||
|
msg: "{{ item.0 }} - {{ item.1 }} - {{ item.2 }}"
|
||||||
|
loop: "{{ data[0]|zip(*data[1:])|list }}"
|
||||||
|
vars:
|
||||||
|
data:
|
||||||
|
- ['a', 'b', 'c']
|
||||||
|
- ['d', 'e', 'f']
|
||||||
|
- ['g', 'h', 'i']
|
||||||
|
|
||||||
with_dict
|
with_dict
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue