If you need to pass a variable to Ansible playbook, using the command line, then you can do the following:
Option 1 – Specifying command line arguments
--extra-vars specified variables will override any variables with the same name defined inside the playbook.
You can also read up on Passing Variables On The Command Line (Wayback Machine link to maintain versioning)
Option 2 – Specify a YML file
You can also specify a
.yml file with the variables:
This can also be enhanced with environment variables: