role directory structure
The fixed set of folders inside a role, such as tasks, handlers, templates, files, defaults and vars, each holding one kind of content.
In more detail
Ansible finds each piece by its location: tasks/main.yml is the entry point, handlers/main.yml holds handlers, templates holds Jinja files, files holds files copied unchanged, defaults/main.yml holds overridable defaults and vars/main.yml holds tightly controlled role variables. A meta folder can list dependencies. Following the layout is what lets both Ansible and a reviewer find things.
Related terms
- Ansible role — A reusable package of tasks, handlers, templates, files and variables for one unit of automation, laid out in a standard directory structure.
- role defaults — The variables in a role's defaults/main.yml: safe starting values that callers are expected to override.
- README — A text file, usually README.md, at the top of a project that explains what it does and how to use it.
Taught in
- The Standard Directory Layout And Roles — Ansible Configuration Management at Scale
- Writing A Role — Ansible Configuration Management at Scale
- Roles: The Directory Ansible Expects, Defaults And Handlers — RHCE in Ansible (EX294): Automate Red Hat Systems