yq parser

From thelinuxwiki
Jump to: navigation, search

file contents:

webserver:
  hosts:
    foo:
      ipaddr: 192.168.1.1
      desc: "foo"
    bar:
      ipaddr: 10.0.0.1
      desc: "bar"


$ yq '.fg.hosts[] | select(.ipaddr == "192.168.1.1")' devices_test.yaml
{
 "ipaddr": "192.168.1.1"
}