How do you pass variables on the command line?
BeginnerConceptVariables, Facts and Precedence
Answer
ansible-playbook site.yml -e "env=prod version=1.4.2"
ansible-playbook site.yml -e '{"packages": ["git", "vim"], "debug": true}'
ansible-playbook site.yml -e @vars/prod.yml
Key=value form always produces strings, so -e "debug=false" is the string "false", which can still be truthy in some contexts. Use JSON or a file for booleans, numbers and lists. Extra vars have the highest precedence.
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