DevOps / Ansible Interview questions
List the components of an Ansible role directory?
A standard role follows a fixed layout that Ansible auto-discovers, with each subdirectory holding a specific kind of content:
- tasks/main.yml - the main list of tasks the role performs.
- handlers/main.yml - handlers the role's tasks can notify.
- defaults/main.yml - lowest-precedence default variable values.
- vars/main.yml - higher-precedence, role-specific variables.
- templates/ - Jinja2 template files rendered onto target hosts.
- files/ - static files copied as-is to target hosts.
- meta/main.yml - role metadata and dependencies on other roles.
Any directory that isn't needed can simply be omitted; Ansible only looks for what's present, which keeps small roles lightweight while still supporting the full structure when a role grows more complex.
More Related questions...