JSON is the correct format to define a hash there.  In the first two
examples you defined two seperate scalar variables with a "." in them.

You can turn on hash merging behavior in ansible.cfg if you wish hash
elements to blend together versus override.

I'll warn you that not all places of the code throughly use it, so you
might hit a kink here or there in 1.4.X, though 1.5 is quite better about
it.


On Tue, Feb 25, 2014 at 4:33 PM, zihaoyu <[email protected]> wrote:

> I have in my playbook this var:
>
> - name: Deploy nodejs app
>   vars:
>     nodejs:
>       name: myapp
>       version: 0.1.1
>       settings:
>         port: 3000
>         log: /var/log
>
> I want to replace or override version and port in this nodejs variable at
> runtime. I've tried:
>
>    1. --extra-vars 'nodejs.version=0.1.2 nodejs.settings.port=4000'
>    2. --extra-vars 'nodejs["version"]=0.1.2
>    nodejs["settings"]["port"]=4000'
>    3. --extra-vars '{"nodejs": {"version": "0.1.2", "settings": {"port":
>    4000}}}'
>
>
> None of them worked. In 1) and 2), the values of version and port are not
> passed in, and in 3), nodejs variable was entirely replaced so that all
> the other values like name and log are gone.
>
> So is there a way to use --extra-vars to override part of a complex
> variable?
>
> Thanks.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5ee29a64-fcce-4aba-8780-5f4ca59ea216%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEVJ8QP%2BtYeup%3DQbxhuHGaB-p1saAb1B9H3AuTp0jXuQLpbrog%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to