-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
None
-
None
-
False
-
-
False
-
en-US (English)
Please fill in the following information:
URL: | https://rol.redhat.com/rol/app/courses/do374-2.2/pages/ch07s05 |
Reporter RHNID: | atcorduneanu@extraordy.com |
Section Title: | h4. Iterating over a List of Lists |
Issue description
The student guide suggests that with_items performs one-level flattening of its lists.
I tried to reproduce to show to my delegates, but I couldn't
Steps to reproduce:
--- - hosts: all gather_facts: false tasks: - set_fact: lista1: "{{ [1, 2, [3, 4, [5]], 6] }}" lista2: "{{ [7, 8, [9]] }}" - name: "with_items task" debug: msg: "{{ item }}" with_items: - "{{ lista1 }}" - "{{ lista2 }}" - name: "loop task" debug: msg: "{{ item }}" loop: "{{ (lista1 | flatten) + (lista2 | flatten) }}"
The playbook above shows how the first debug task (with_items task) does not iterate on a flat list, but the second does (loop task)
Workaround:
using loop keyword instead of with_items..
Expected result:
{}I would expect the student guide to be corrected on the paragraph:
"The with_items keyword combines these three lists into a single list containing the entries from all three lists. It automatically performs one-level flattening of its list"
or more context provided. Or a reference to an example and documentation attached to this issue, in the case that I'm wrong.