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>
This commit is contained in:
Jakub Sokołowski 2021-08-28 11:05:04 +02:00
parent 7a6960d559
commit 4e45ee72c6
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 10 additions and 0 deletions

10
consul/gen_hosts.sh Executable file
View File

@ -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