Essential terminology
IndentationSpaces at the beginning of a line that show nesting and relationships. YAML commonly uses two spaces per level; avoid tabs.
Parent keyA key that contains indented data beneath it. In
dnf:, the module is parent to its arguments.Child keyA key nested under a parent.
name and state are children of dnf.Mapping (dictionary)A collection of key–value pairs, such as
name: git. It answers “which value belongs to which key?”Sequence (list)An ordered collection. Each list item normally begins with a hyphen and a space:
- git.List itemOne element of a sequence. In a package list,
git, curl, and tree are separate items.KeyThe label before the colon, such as
hosts, tasks, name, or state.ValueThe data assigned to a key, such as
present in state: present.ScalarA single value: a string, number, Boolean, or null. Examples include
Ansible, false, and 200.Nested structureA mapping or list contained inside another mapping or list, represented through deeper indentation.
PlaybookA YAML file containing one or more plays. The top level is normally a sequence of plays.
PlayA mapping that connects targeted hosts with an ordered set of tasks.
TaskOne named unit of work in the
tasks list. A task normally calls one module.ModuleThe Ansible unit that performs work, such as
file, copy, dnf, or ping.Module argumentAn input passed to a module. For
file, examples include path, state, and mode.KeywordAn Ansible-defined playbook term such as
hosts, tasks, become, or gather_facts.Block scalar |Introduces multiline text and preserves line breaks. It is useful with
copy: content:.Variable expressionText inside double braces, such as
{{ inventory_hostname }}, evaluated by Ansible at runtime.Annotated example
dnf: # parent key and module
name: # child of dnf; its value is a list
- git # list item
- curl # list item
- tree # list item
state: present # child key: scalar value
Parent: dnfChildren: name, stateList items: git, curl, treeScalar: present
25-question knowledge check
Select one answer per question. Feedback appears immediately. The quiz submits automatically when the 20-minute timer reaches zero.
Final result
0/25