Hello - i’m trying to figure out how to do this if the data isn’t JSON:
json_query(host[?name==‘webserver’].ipaddress)
In other words, I want to return an attribute from a list based on a condition. I’m trying to combine data from multiple lists over a shared key.
example:
-
system1
-
host: demo1
ipaddress: 192.168.20.20 -
host: demo4
ipaddress: 192.168.20.30 -
systemstatus
-
system: demo4
status: faulty -
system: web5
status: operational
What I would like returned is a single list:
result:
- host: demo4
ipaddress: 192.168.20.30
status: faulty
Currently I’m just looping through “systemstatus” but I how do you do the simple json query above to extract the data from “example”. Or if it helps, I am getting data from a 3rd system and I would like to use it to update the inventory data I have about hosts “I know about”. And I keep coming up short on how to select from an list based on a condition that isn’t the index of the array it’s implemented in.