The Role Directory Anatomy
tasks, handlers, templates, defaults, vars.
A Role Is a Folder Tree
A role is just a directory with a fixed set of subfolders. Ansible knows each folder by name and loads its contents automatically.
roles/
nginx/
tasks/
handlers/
templates/tasks/main.yml Is the Entry Point
The tasks/main.yml file holds the role's main list of tasks. It is the first thing Ansible runs when the role is applied.
tasks/main.yml:
- name: Install nginx
ansible.builtin.package:
name: nginx