Creating valid variable names
Not all strings are valid Ansible variable names. A variable name can only include letters, numbers, and underscores.Python keywordsorplaybook keywordsare not valid variable names. A variable name cannot begin with a number.
Variable names can begin with an underscore. In many programming languages, variables that begin with an underscore are private. This is not true in Ansible. Ansible treats variables that begin with an underscore the same as any other variable. Do not rely on this convention for privacy or security.
This table gives examples of valid and invalid variable names:
Ansible defines certainvariablesinternally. You cannot define these variables.
Avoid variable names that overwrite Jinja2 global functions listed inWorking with playbooks, such aslookup,query,q,now, andundef.