0Pricing
Ansible Academy · Lesson

Looping Over Dictionaries

Create users from key-value data.

Lists Are Not Enough

Creating users needs more than a name: a group, a shell, a state. A flat list cannot carry that. You need a list of dictionaries. 🗂️

A List of Dictionaries

Each list entry becomes a small dictionary of key-value pairs. One loop iteration then has several named fields to work with.

loop:
  - { name: alice, group: admin }
  - { name: bob, group: dev }

All lessons in this course

  1. The loop Keyword Over a List
  2. Looping Over Dictionaries
  3. Nested Loops with subelements
  4. loop_control: label, index & pause
← Back to Ansible Academy