2021-10-12 19:24:31 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
juju_status=$(mktemp)
|
|
|
|
|
|
|
|
juju status --format json > $juju_status
|
|
|
|
|
2022-01-27 10:08:00 +00:00
|
|
|
# old method
|
|
|
|
#cat ${juju_status} | jq -rc '.machines | to_entries[] |[.key,.value.hostname,.value."ip-addresses"]'
|
|
|
|
#cat ${juju_status} | jq -rc '.machines | to_entries[] | select(.value.containers != null ) | .value.containers | to_entries[] | [.key,.value.hostname,.value."ip-addresses"]'
|
|
|
|
|
|
|
|
# new method
|
2023-02-22 14:16:27 +00:00
|
|
|
jq -rc '.machines | to_entries[] |[.key,.value.hostname,.value."ip-addresses", [(.value.containers//empty | to_entries[] | [.key,.value.hostname,.value."ip-addresses"])]]' ${juju_status}
|
2021-10-12 19:24:31 +00:00
|
|
|
|