What naming conventions do you enforce?
BeginnerProductionProject Structure and Design
Answer
- Roles: lowercase with underscores, named after the service (
nginx,node_exporter). - Variables: role-prefixed (
nginx_worker_connections), secrets prefixedvault_, internal ones__role_name_x. - Tasks: start with a capital letter and a verb, optionally prefixed with the role (
nginx | Install package), so the run output is searchable. - Handlers: unique and prefixed.
- Files:
.ymlextension everywhere, one style.
ansible-lint enforces most of this, which removes the style arguments from code review.
More on Project Structure and Design
What does a production Ansible repository look like?BeginnerMonorepo or separate repos for roles? How do you decide?IntermediateHow do you structure inventories for dev, stage and prod?BeginnerHow do you prevent someone from running a playbook against production by accident?IntermediateWhat does "thin playbooks, fat roles" mean?IntermediateWhat makes a well-designed role?Intermediate