infra-utils/consul/gen_hosts.sh
Jakub Sokołowski 4e45ee72c6
consul/gen_hosts: script for generating hosts entries
This is useful when DNS issues make the statusim.net domain unusable.
You can connect to a Consul host using an IP and tunnel `8500` port:
```
ssh -L 8500:localhost:8500 admin@178.128.136.23
```

Signed-off-by: Jakub Sokołowski <jakub@status.im>
2021-08-28 11:05:34 +02:00

11 lines
295 B
Bash
Executable File

#!/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