It works OK, thanks.

 - name: LIST id HC
    debug:
       var=hc.json.results|json_query('[?name==`{{host_collection}}`].id')


TASK [LIST id HC] 
*******************************************************************************************************************************************
ok: [] => {
    "hc.json.results|json_query('[?name==`hc1`].id')": [
        693
    ]
}

But I have another problem.
I want to use that variable for another uri execution, but i don´t know how 
to pass the value to a var.

I tried with this, but it fails:


- set_fact:
    *   hc_id: 
"{{hc.json.results|json_query('[?name==`{{host_collection}}`].id')}}"*

  - name: LIST id HC
    debug:
       var=hc_id

  - name: GET INFO NODES HOST COLLECTION
    uri:
       url: "https://xxxxxxx/katello/api/host_collections/{{hc_id}}/";
       user: "{{user}}"
       password: "{{password}}"
       method: GET
       return_content: yes
       force_basic_auth: yes
       validate_certs: no
       headers:
               Content-Type: "application/json"
       status_code: [200,201,202,204,301,401]
    register: hc_info

  - name: LIST id HC
    debug:

hc_id variable is empty:

TASK [set_fact] 
*********************************************************************************************************************************************
ok: [ssh.sva.itbatera.ejgv.eus]

TASK [LIST id HC] 
*******************************************************************************************************************************************
ok: [ssh.sva.itbatera.ejgv.eus] => {
    "hc_id": []
}


El lunes, 22 de octubre de 2018, 18:02:14 (UTC+2), Vladimir Botka escribió:
>
> Try
>>
>
>      - debug: var=hc.json.results|json_query('[?name==`hc1`].id')
>
>

-- 
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/223685c3-be39-4492-9c0f-c8e82dd49b90%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to