There are 20+ ways to create variables in Ansible, such as on the command line, in a playbook, or from a file, just to name a few.
Common ways to create variables
Following are common ways that variables are created. This is in the order of precedence, top down, where the option higher in the list takes precedence.
Ansible uses Jinja2 templating for variables. In Jinja2, a variable has this structure.