Hi All,
I am trying to run an ansible playbook from jenkins build to have jenkins trigger my ansible execution.
As part of my ansible-playbook run i need to pass extra-vars to the playbook during execution.
eg:
ansible-playbook -i $inventory-file $role-name --extra-vars"var1=$var1-value, var2=$var2-value"
when i put this line in the execute shell of jenkins the double quotes are evaluated and so aren’t available to the ansible-playbook command, so i escaped them as follows:
ansible-playbook -i $inventory-file $role-name --extra-vars"var1=$var1-value, var2=$var2-value"
But if i do this,
shell adds extra quotes around it as below:
ansible-playbook -i --extra-vars ’ "var1=var1-value,’ var2=var2-value, 'var3=var3-value " ’
And ansible give the following error:
Traceback (most recent call last):
File “/usr/local/bin/ansible-playbook”, line 317, in
sys.exit(main(sys.argv[1:]))
File “/usr/local/bin/ansible-playbook”, line 148, in main
extra_vars = utils.combine_vars(extra_vars, utils.parse_kv(extra_vars_opt))
File “/Library/Python/2.7/site-packages/ansible/utils/init.py”, line 621, in parse_kv
vargs = split_args(args)
File “/Library/Python/2.7/site-packages/ansible/utils/splitter.py”, line 148, in split_args
raise Exception(“error while splitting arguments, either an unbalanced jinja2 block or quotes”)
Exception: error while splitting arguments, either an unbalanced jinja2 block or quotes
Has anyone come across such a situation before ?