Folks, trying to get json query for the below data's. Tried the below queries but didn't get output as expected. can someone help me . Try 1: ++++++++++++++++++++++++++ register: result - name: Display PSU status debug: msg="{{ result.json | json_query(jmesquery) }}" vars: jmesquery: "[*].{dn: dn, id: id}" ++++++++++++++++++++++++++++ Try:2 # msg: "{{ result|json_query('configResolveClass.children[0].outConfigs.children[0].equipmentPsu.attributes.equipmentPsu.attributes[0].{dn: dn, id: id, operability: operability, presence:presence}') }}" +++++++++++++++++++++++++++++
Ansible Facts: +++++++++++++++++++++++++++ "aaaLogin": { "attributes": { "cookie": "", "outCookie": "1609339398/bec3ca01-b7af-17af-a0f6-bc16ee6a0f70", "outPriv": "admin", "outRefreshPeriod": "600", "outSessionId": "8446", "outVersion": "3.1(3a)", "response": "yes" } }, "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python3" }, "changed": false, "configResolveClass": { "attributes": { "classId": "equipmentPsu", "cookie": "1609339398/bec3ca01-b7af-17af-a0f6-bc16ee6a0f70", "response": "yes" }, "children": [ { "outConfigs": { "attributes": {}, "children": [ { "equipmentPsu": { "attributes": { "dn": "sys/rack-unit-1/psu-1", "fwVersion": "12002216", "id": "1", "input": "135", "maxOutput": "NA", "model": "700-014160-0000", "operability": "operable", "output": "118", "pid": "UCSC-PSU1-770W", "power": "on", "presence": "equipped", "serial": "ART2221F58Q", "thermal": "ok", "vendor": "Cisco Systems Inc", "voltage": "ok" } } }, { "equipmentPsu": { "attributes": { "dn": "sys/rack-unit-1/psu-2", "fwVersion": "12002216", "id": "2", "input": "140", "maxOutput": "NA", "model": "700-014160-0000", "operability": "operable", "output": "127", "pid": "UCSC-PSU1-770W", "power": "on", "presence": "equipped", "serial": "ART2221F4XS", "thermal": "ok", "vendor": "Cisco Systems Inc", "voltage": "ok" } } } ] } } ] }, "elapsed": 3, "invocation": { "module_args": { "content": "<configResolveClass inHierarchical=\"false\" classId=\"equipmentPsu\"/>\n", "hostname": "host1", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "path": null, "protocol": "https", "timeout": 60, "username": "VIPER_VIO", "validate_certs": false } }, "response": "OK (unknown bytes)", "status": 200 } ++++++++++++++++++++++++++++++++++++++++++++++++++++ Thanks, Ramesh -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2da6748f-ae6e-4f05-8def-8d71520a43c3n%40googlegroups.com.