Interview Prep/Ansible/Variables, Facts and Precedence

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.

All Ansible questions Roadmap: Ansible

More on Variables, Facts and Precedence