Re: [ansible-project] Ansible playbook --extra-var with dot in json key

2018-02-23 Thread Foss Geek


On Friday, February 23, 2018 at 5:06:39 PM UTC+5:30, Kai Stian Olstad wrote:
>
> On 23.02.2018 12:22, Foss Geek wrote: 
> > # cat /tmp/test.json | jq 
> > { 
> >   "VMware.Hardware.Version": " vmx-10", 
> > 
> >   "toolname": "tomcat" 
> > 
> > } 
> > 
> > 
> > Playbook: 
> > 
> > 
> > # cat test.yml 
> > 
> > --- 
> > 
> > host: myhost 
> > 
> > vars: 
> > 
> >   hdversion: "{{ VMware.Hardware.Version }}" # not works due to 
> > dot(.), getting VARIABLE NOT DEFINED when try to reference hdversion 
> > inside role 
> > 
> >   mytoolname: "{{toolname}}"  # works fine 
> > 
> > 
> > any workaround to use hdversion: "{{ VMware.Hardware.Version }}" to 
> > get the value? 
> > 
> > Any advise or guidance would be greatly appreciated. 
>
> This should work 
>{{ vars['VMware.Hardware.Version'] }} 
>
>
> -- 
> Kai Stian Olstad 
>

Oh. That helps. Thank you very much. 

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/a03f39fb-dbcb-4145-8700-c60cd237ff73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Ansible playbook --extra-var with dot in json key

2018-02-23 Thread Kai Stian Olstad

On 23.02.2018 12:22, Foss Geek wrote:

# cat /tmp/test.json | jq
{
  "VMware.Hardware.Version": " vmx-10",

  "toolname": "tomcat"

}


Playbook:


# cat test.yml

---

host: myhost

vars:

  hdversion: "{{ VMware.Hardware.Version }}" # not works due to
dot(.), getting VARIABLE NOT DEFINED when try to reference hdversion
inside role

  mytoolname: "{{toolname}}"  # works fine


any workaround to use hdversion: "{{ VMware.Hardware.Version }}" to
get the value?

Any advise or guidance would be greatly appreciated.


This should work
  {{ vars['VMware.Hardware.Version'] }}


--
Kai Stian Olstad

--
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/be47e32657e17d52b056a1220fb84b5a%40olstad.com.
For more options, visit https://groups.google.com/d/optout.