uvok on Nostr: Got output from ansible across several hosts with ip -6 -j a show (In the form of ...
Got output from ansible across several hosts with
ip -6 -j a show
(In the form of {"host": "...output...",...})
Wanted to get a nice overview of host/interface/ip addresses.
Tried jq, got as far as
jq '[to_entries[] | .value = [(.value[].ifname)]] | from_entries'
Said "FUCK IT" and went with this Python:
for host,cont in jj.items():
print(host)
for ifinfo in cont:
print(f" {ifinfo['ifname']}")
for adr in ifinfo["addr_info"]:
print(f" {adr['local']}")
Know when to use which tool!
ip -6 -j a show
(In the form of {"host": "...output...",...})
Wanted to get a nice overview of host/interface/ip addresses.
Tried jq, got as far as
jq '[to_entries[] | .value = [(.value[].ifname)]] | from_entries'
Said "FUCK IT" and went with this Python:
for host,cont in jj.items():
print(host)
for ifinfo in cont:
print(f" {ifinfo['ifname']}")
for adr in ifinfo["addr_info"]:
print(f" {adr['local']}")
Know when to use which tool!