What is a playbook?
BeginnerConceptPlaybooks, Plays, Tasks and Handlers
Answer
A playbook is a YAML file containing a list of plays. Each play maps a group of hosts to an ordered list of tasks, where each task calls one module with arguments. It is the reusable, version-controlled replacement for a sequence of ad-hoc commands.
- name: Configure web servers
hosts: web
become: true
tasks:
- name: Install nginx
ansible.builtin.package:
name: nginx
state: present
More on Playbooks, Plays, Tasks and Handlers
What are the main keys of a play?BeginnerWhy should every task have a `name`?BeginnerWhich playbook flags help you inspect and debug before a real run?BeginnerWhat is a handler and how is it triggered?BeginnerWhat are the behaviours and gotchas of handlers?IntermediateHow do you run handlers immediately instead of at the end of the play?Intermediate