CertGrid CertGrid
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

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.

The playbook targets the `web` group, so it runs against one managed node.
Server NameIP AddressOSRolesCPURAMHDD
ANS-CTL01192.168.0.36Ubuntu 26.04 LTSAnsible Control Node2 Core3 GB50 GB
ANS-A01192.168.0.37Ubuntu 26.04 LTSManaged Node (group: web)2 Core3 GB50 GB
ANS-B01192.168.0.38Ubuntu 26.04 LTSManaged Node (group: db)2 Core3 GB50 GB

Before you start

  1. The configuration this guide assumes

  2. A playbook is a list of plays

  3. Check before you run

  4. Run it

  5. Run it again

  6. What a broken playbook looks like

Official sources