On Tuesday, 23 October 2018 10:33:55 CEST Alberto Jimenez Lozano wrote:
> I tried with
> 
> vars:
>        hc_id: 
> "{{hc.json.results|json_query('[?name==`{{host_collection}}`].id')}}"
> 
> And with
> 
> vars:
>       hc_id: 
> "{{hc.json.results|json_query('[?name==`\"{{host_collection}}\"`].id')}}"
> 
> But the variable is empty always.
> 
> TASK [LIST id HC] 
> *******************************************************************************************************************************************
> ok: [] => {
>     "hc_id": []
> }
> 
> The problem is that I have a variable {{host_collection}} into another 
> variable definition and I have to scaped the {} symbols, no?

You can't use {{ }} inside {{ }}, you'll need to use Jinja concatenation
I'm not 100% sure if this is correct but you can try:


 "{{ hc.json.results | json_query('[?name==`' ~ host_collection ~ '`].id') }}"

 

-- 
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 [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/7031381.vbdtAvJjsP%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to