Nested Loops with subelements
Iterate lists inside lists.
Lists Inside Lists
Sometimes each item owns its own list: a user with several SSH keys, a group with many members. That is a nested structure. 🪆
The subelements Lookup
The subelements lookup pairs each parent with each child in its inner list, flattening the nesting into single iterations.
loop: "{{ users | subelements('keys') }}"All lessons in this course
- The loop Keyword Over a List
- Looping Over Dictionaries
- Nested Loops with subelements
- loop_control: label, index & pause