У меня в качестве примера есть этот блок json:
"msg": {
"10.10.28.10": {
"core": 23,
"cpuCoreUsage": 0.0,
"cputhreshold": 80,
"status": "healthy",
"status_code": 0,
"status_reason": "Checks passed",
"timestamp": 1614281443,
"total": 0
},
"10.10.28.5": {
"core": 18,
"cpuCoreUsage": 2.0,
"cputhreshold": 80,
"status": "healthy",
"status_code": 0,
"status_reason": "Checks passed",
"timestamp": 1614281443,
"total": 0
},
"capacity": 1080
}
Я пытаюсь понять, как я могу получить этот вывод с именем свойства и статусом, чтобы он выглядел примерно так.
DESIRED OUTPUT:
IP: 10.10.28.5, status: healthy, status_code: 0
IP: 10.10.28.10, status: healthy, status_code: 0
Я могу распечатать все, кроме IP-части, следующим образом:
- name: STATUS QUERY
debug:
msg: "code: {{ item }}"
loop: "{{ data.json | json_query(status_code_query) | list }}"
vars:
status_code_query: "*.{statuscode: status_code, status: status}"