35238/pass-variable-to-ansible-playbook-through-command-line
ansible-playbook test.yml --extra-vars "arg1=${var1} arg2=${var2}"
Use is like this in the yml file:
--- arg1: "{{ var1 }}" arg2: "{{ var2 }}"
It is possible to set variables at the command line using the --extra-vars argument. Variables can be defined using a single quoted string (containing one or more variables) using one of the formats below
key=value format:
ansible-playbook release.yml --extra-vars "version=1.23.45 other_variable=foo"
You can also try this:
ansible-playbook release.yml -e "version=1.23.45 other_variable=foo"
the -e flag here is the shard form for --extra-vars
Try this if you want to pass multiple variables:
ansible-playbook site.yaml -i hostinv -e firstvar=false -e second_var=value2
Hello,
Glad to hear that!! If you found this is helpful you can upvote the answer!!
Thank You!
Just go through the error message: Ansible can't ...READ MORE
Hi@akhtar, Variable in playbooks are very similar to using variables in ...READ MORE
Hi, When we run any file from Jenkins, ...READ MORE
Hi@akhtar, Ansible has a very attractive command named ...READ MORE
Hey @nmentityvibes, you seem to be using ...READ MORE
Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE
It can work if you try to put ...READ MORE
When you use docker-compose down, all the ...READ MORE
Hey @Celia, one recommendation, try not using ...READ MORE
Hey @Reshma, You can use the URI ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.