Hands-on Lab·Ansible
Ansible Playbook Basics
A playbook is a YAML file containing a list of plays, and a play is a list of tasks aimed at a pattern of hosts. This writes one with four tasks, runs the two checks worth running first, executes it, runs it again to see every task report `ok`, and finishes by breaking the YAML on purpose so the parser error is recognisable.
Plays and Playbooks Guide 10 of 45 Beginner
- OSUbuntu 26.04 LTS
- ansible-core2.20.1
- Python3.14.4
- TimeAbout 15 min
- Reviewed23 August 2026
Written against the versions above. `--syntax-check` parses the YAML and the play structure without contacting any host. It will not catch a wrong module parameter or an undefined variable - those surface at run time - but it catches indentation, which is the mistake that actually happens.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| ANS-CTL01 | 192.168.0.36 | Ubuntu 26.04 LTS | Ansible Control Node | 2 Core | 3 GB | 50 GB |
| ANS-A01 | 192.168.0.37 | Ubuntu 26.04 LTS | Managed Node (group: web) | 2 Core | 3 GB | 50 GB |
| ANS-B01 | 192.168.0.38 | Ubuntu 26.04 LTS | Managed Node (group: db) | 2 Core | 3 GB | 50 GB |
Before you start
- A control node configured as shown in the first step.
- The session creates
~/pb/site.yml, applies it to/opt/demoappon the managed node, and removes the directory at the end.
-
The configuration this guide assumes
-
A playbook is a list of plays
-
Check before you run
-
Run it
-
Run it again
-
What a broken playbook looks like