What is an Ansible role?
⚡
Quick Answer
A role is a standardized directory structure that packages related tasks, variables, templates, files, and handlers into a reusable, shareable unit of automation.
Detailed Answer
Roles turn sprawling playbooks into composable building blocks (for example an nginx role or a base-hardening role) with a conventional layout (tasks/, templates/, defaults/, handlers/, meta/). They can be versioned and shared via Ansible Galaxy and included across projects, keeping automation DRY.
💡
Interview Tip
Say roles make playbooks reusable and DRY, and mention Ansible Galaxy for sharing them.
ansiblerolesreuse