LOGBOOK

HELP

Quiz Entry - updated: 2026.10.30

A playbook contains two top-level items, - name: Webserver einrichten (keys hosts, vars, tasks; three tasks for yum, service and firewalld) and - name: Datenbankserver einrichten. How many plays and tasks are there, and how do you tell?

Two plays, because the outermost list has two dash items; the first play has three tasks, because its tasks list has three dash items. Plays and tasks are both objects; the playbook and tasks are lists.

Reading procedure, which works on any playbook:

  1. Find the outermost dashes. Each - at column 0 (after the start marker) starts a play. Two dashes, two plays: "set up web server" and "set up database server" ("Webserver einrichten" and "Datenbankserver einrichten" in the German example).
  2. Look at what follows a play's dash without dashes. name, hosts, vars, tasks are key-value pairs at the same indentation, so the play is an object.
  3. Open the tasks key. Its value is a list; count the dashes one level in. In the first play: ensure Apache is installed (ansible.builtin.yum), start the Apache service (ansible.builtin.service), allow the Apache port in the firewall (ansible.builtin.firewalld). Three tasks.
  4. Each task is an object again: a name plus a module key whose value is another object of arguments.

The vars: block (http_port: 80) is a named object inside the play; the firewall task uses it as port: "{{ http_port }}/tcp", so the port is defined once and reused.

Go deeper:

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