Automation · Configuration Management
Roles
Cheat sheet · https://pcornel.dk/topic.php?topic=5385
Answer
Roles package related tasks, templates, files, variables and handlers into reusable units, such as an Ansible role for nginx, so a server's configuration is built from tested building blocks.
Remember
- Roles package tasks, templates, files, variables and handlers.
- Test roles with tools like Molecule.
- Version roles and pin them.
First checks
ansible-galaxy role init <role>— skeletonansible-lint roles/<role>— lintmolecule test— role tests
Verify in this order
role → tasks/handlers/templates → hosts
Where it usually breaks
Inventory/vars → play/task selection → connection/become → module request → module result → target object read-back → handler/service effective state → workload verification.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5385