What are the naming rules for variables, and why prefix role variables?
BeginnerConceptVariables, Facts and Precedence
Answer
Names must be letters, digits and underscores, start with a letter or underscore, and must not be Python keywords or reserved names like environment, name or hosts used as play keywords. No dashes or dots.
Role variables share one global namespace per host, so prefix them with the role name (nginx_port, postgres_version) to avoid collisions. Variables meant to be private get a double prefix __nginx_pkg, which is the community convention.
More on Variables, Facts and Precedence
Where can you define variables in Ansible?BeginnerHow do you reference a variable, and when must you quote it?BeginnerGive a summary of variable precedence.IntermediateWhat are the lowest and highest precedence sources, and why does that matter?IntermediateWhat is the difference between a role's `defaults/` and `vars/`?IntermediateWhat are facts and how are they gathered?Beginner