ansible-community / ara

ARA Records Ansible and makes it easier to understand and troubleshoot.

Home Page:https://ara.recordsansible.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The controller hostname recorded by ara for the controller can be something like 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa (on OS X?)

dmsimard opened this issue · comments

What is the issue ?

Using ara under Mac OS X, the hostname that python picks up on my machine is 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa which isn't particularly useful when the hostname and hostname -f commands both return a proper hostname like laptop.example.org.

Screenshot from 2022-12-21 17-45-08

We rely on python's socket.getfqdn() and socket.gethostname() to retrieve the hostname:

if self.localhost_as_hostname_format.startswith("fqdn"):
hostname = socket.getfqdn()
if self.localhost_as_hostname_format.startswith("hostname"):
hostname = socket.gethostname()

On OS X (at least on my machine, I'm an OS X noob), getfqdn returns the ipv6 arpa mentioned previously and gethostname returns the actual hostname.

What should be happening ?

There's settings that determine which format is used:
Screenshot from 2022-12-21 18-04-11

In this particular case, hostname would probably be a better default than fqdn. Is this generally true for all distros ?

Changing it could result in playbooks being associated to a "new" controller if the fqdn and hostname are not the same.

Happy to hear what you think.

In this particular case, hostname would probably be a better default than fqdn. Is this generally true for all distros ?

on Debian 11 here:

socket.getfqdn() -> laptop.example.org
socket.gethostname() -> laptop

I prefer getfqdn much more since gethostname could not be unique.