Interview Prep/Ansible/Project Structure and Design

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.

All Ansible questions Roadmap: Ansible

More on Project Structure and Design