useful_scripts/get_all_ips.sh

14 lines
606 B
Bash
Raw Normal View History

2021-10-12 19:24:31 +00:00
#!/bin/bash
juju_status=$(mktemp)
juju status --format json > $juju_status
# 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
cat ${juju_status} | jq -rc '.machines | to_entries[] |[.key,.value.hostname,.value."ip-addresses", [(select(.value.containers != null ) | .value.containers | to_entries[] | [.key,.value.hostname,.value."ip-addresses"])]]'
2021-10-12 19:24:31 +00:00