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}') }}"
"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
}