socket.gethostbyname(hostname) works OK so long as /etc/hosts does not contain:
127.0.1.1 hostname.domainname hostname
In which case 127.0.1.1 is returned; which is not desirable.
I've continually come up against this challenge using Juju with providers that return a hostname rather than an IP address for `private-address`.
dig +short hostname works OK so long as hostname is a direct A record; if its a CNAME it breaks; I'll give this all another round of thinking and see what other approaches might be taken.
Hi Adam
socket. gethostbyname( hostname) works OK so long as /etc/hosts does not contain:
127.0.1.1 hostname.domainname hostname
In which case 127.0.1.1 is returned; which is not desirable.
I've continually come up against this challenge using Juju with providers that return a hostname rather than an IP address for `private-address`.
dig +short hostname works OK so long as hostname is a direct A record; if its a CNAME it breaks; I'll give this all another round of thinking and see what other approaches might be taken.
Thanks for the reviews....