MAAS × LXD

08 · jq for Operations

MAAS CLI returns JSON. jq lets you turn that into readable tables so you can operate comfortably from the terminal.

Readable inventory

maas admin machines read | jq -r '(["HOSTNAME","SYSID","POWER","STATUS","OWNER","POOL","VLAN"]
 | (., map(length*"-"))),
 (sort_by(.hostname)[] | [.hostname,.system_id,.power_state,.status_name, (.owner // "-"), .pool.name, .boot_interface.vlan.name])
 | @tsv' | column -t

Filter to Ready

maas admin machines read | jq -r '.[] | select(.status_name=="Ready") | [.hostname,.system_id] | @tsv'

Sort by multiple fields

maas admin machines read | jq -r '(sort_by(.pool.name, .hostname)[] | [.hostname, .pool.name, .zone.name]) | @tsv' | column -t