You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
A playbook is the heart of Ansible automation. While ad-hoc commands handle one-off tasks, playbooks let you define complex, multi-step workflows in a structured, repeatable, and version-controlled YAML file.
A playbook is a YAML file containing one or more plays. Each play maps a group of hosts to a set of tasks to be executed.
Playbook
+-- Play 1 (hosts: webservers)
| +-- Task 1
| +-- Task 2
| +-- Task 3
+-- Play 2 (hosts: dbservers)
+-- Task 1
+-- Task 2
- ): )# A list
fruits:
- apple
- banana
- cherry
# A dictionary
server:
name: web1
port: 80
enabled: true
---
- name: Configure web servers
hosts: webservers
become: true
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.