LOGBOOK

HELP

Quiz Entry - updated: 2026.10.30

What are a key-value pair, an object and a list in YAML, and when do you use a dash?

A key-value pair is key: value. An object (mapping) groups several key-value pairs at the same indentation, without dashes. A list (sequence) groups items, each starting with a dash and a space.

Three YAML building blocks side by side: a key-value pair, an object of three pairs without dashes, and a list of three items with dashes, plus a list of two objects

* Dashes mark list items; keys at the same indentation without dashes form one object. *

name: "Alice"          # key-value pair

name: "Bob"            # object: three pairs belong together
age: 30
active: true

- apple                # list of scalars
- banana
- cherry

The rule that resolves most confusion: a dash starts a new list item, nothing else. Keys of an object need no dash, because the parser can already tell from the indentation and the key: colons which pairs belong together. If you put a dash in front of each key of what should be one object, you get a list of three one-key objects instead.

In Ansible's own vocabulary you will also meet "dictionary" or "mapping" for object, and "sequence" for list.

Go deeper:

From Quiz: ITIA / Ansible Inventory, Configuration and Playbooks | Updated: Oct 30, 2026