Parsing json outputs not returning expected results.

88 views
Skip to first unread message

Darshan Yamakanamardi

unread,
Feb 9, 2021, 10:10:13 PM2/9/21
to Ansible Project
Hello All,

I am trying to parse JSON output and use it as a variable in a playbook. Whilst the JSON query works perfectly fine if I run it on the bash command line, but for some reason, Ansible is not parsing the JSON output as expected. The play book and play recap are available at the below URL. 


In the play recap, the debug output returns a null value.   msg = " "
However, in the below screenshot from https://jsonpath.com/ which I used to test the JSON query. I am not sure if I am missing something in the playbook. I reviewed the ansible documentation but I couldn't find any pointers. Could you please help me to achieve the expected result?

Regards,
Darshan
Screen Shot 2021-02-10 at 1.23.23 pm.png

Dick Visser

unread,
Feb 10, 2021, 12:16:21 AM2/10/21
to ansible...@googlegroups.com
  1. Try:


    - debug:
    msg: "{{ output|json_query('results[0].name') }}"






--
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-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a54d0e43-b7e9-43ba-952e-602ff1900669n%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Darshan Yamakanamardi

unread,
Feb 10, 2021, 12:34:59 AM2/10/21
to ansible...@googlegroups.com
Thank you mate. It worked. I appreciate your help on this. 

Regards,
Darshan


Reply all
Reply to author
Forward
0 new messages