What does "thin playbooks, fat roles" mean?
IntermediateProductionProject Structure and Design
Answer
Playbooks should only map hosts to roles (and maybe set a few parameters), while the logic lives in roles. That makes playbooks readable as an architecture overview and makes the logic reusable and testable.
- hosts: web
become: true
roles:
- role: common
- role: nginx
- role: app
If a playbook contains hundreds of lines of tasks, it is a role waiting to be extracted. The opposite trap is a role per package with a sprawl of dependencies, so aim for roles that represent a service or capability.
More on Project Structure and Design
What does a production Ansible repository look like?BeginnerMonorepo or separate repos for roles? How do you decide?IntermediateHow do you structure inventories for dev, stage and prod?BeginnerHow do you prevent someone from running a playbook against production by accident?IntermediateWhat makes a well-designed role?IntermediateWhat goes into a project-level `ansible.cfg` for production?Beginner