5

I have some variables in my playbook as follows:

--- first_var: param1: value1 param2: value2

And I want to call these parametres from the commandline as follows:

ansible-playbook -i inventory site.yml -e 'first_var.param1=newvalue1'

But doesn't work, am I missing something?

1 Answer 1

4

You can do this only if you modify hash-behaviour to merge (this can potentialy brake your playbooks).
Also for this to work, you need to pass extra variables as JSON object, this will not work for -e var=value.

Example command line:

ANSIBLE_HASH_BEHAVIOUR=merge ansible-playbook -i inventory -e "{'first_var':{'param1':'newvalue1'}}" site.yml
Sign up to request clarification or add additional context in comments.

1 Comment

That's it, Thank you very much (^_^)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.