diff --git a/consul/gen_hosts.sh b/consul/gen_hosts.sh new file mode 100755 index 0000000..90b180c --- /dev/null +++ b/consul/gen_hosts.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +CONSUL_URL="${CONSUL_URL:-http://localhost:8500/v1/catalog}" + +readarray -t DCS < <(curl -s "${CONSUL_URL}/datacenters" | jq -r '.[]') + +for DC in "${DCS[@]}"; do + echo "# DC: ${DC}" + curl -s "${CONSUL_URL}/nodes?dc=${DC}" | jq -r '.[] | [.Address, .Node] | @tsv' +done