Quiz Entry - updated: 2026.10.30
What are a "named object", a "named list" and a list of objects in YAML?
A named object is a key whose value is an object; a named list is a key whose value is a list; a list of objects is a list whose items are objects (a dash starts each object, its other keys line up below it without dashes).
user: # named object (key-value pair with an object)
name: "Bob"
age: 30
fruits: # named list (key-value pair with a list)
- apple
- banana
users: # named list whose items are objects
- name: Alice
role: admin
- name: Bob
role: user
Rules worth remembering:
- A key-value pair can hold anything as its value: a scalar, an object or a list.
- Keys inside an object have no dashes. Only list items do.
- An object always consists of key-value pairs. There is no object "directly with" a list; a list can only appear as the value of a key (or as an item of another list).
- In
users, the list has three items (dashes) and each item is an object with two keys. The dash belongs to the first key of each object;rolelines up undernamewith no dash because it is in the same object.
This last shape, a named list of objects, is exactly what tasks: in a play is.
Go deeper:
YAML Syntax (official docs) โ nested lists and dictionaries as Ansible uses them.