I'm using the "sidekick" pattern to announce the hostanme of the first node in a cluster:
ExecStart=/bin/sh -c "while true; do etcdctl set /services/couchbase/bootstrap_ip '%H\' --ttl 60;sleep 45;done"
When I run this on AWS, they have this hostname in their dns, so I'm able to connect to it directly:
$ etcdctl get /services/couchbase/bootstrap_ip
ip-10-150-73-56.ec2.internal
$ ping ip-10-150-73-56.ec2.internal
PING ip-10-150-73-56.ec2.internal (10.150.73.56) 56(84) bytes of data.
On Vagrant, however, it's a different story. I end up with "core-01" as the value emitted from %H in the fleetfile, and I don't know of any way to find the ip address from the hostname.
I didn't see a way in the
Systemd man page to emit the ip address of the node. I did see
%m Machine ID, but didn't see a way to lookup an ip address from a Machine ID in fleetctl.Or if there was an easy way to setup a hosts -> ip mapping in Vagrant, that would solve my problem. I guess it could write the host->ip mapping to /etc/hosts on each machine.
Any tips?