Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
ansible_hostname_f: a platform fact mimicking `hostname -f` #56424
There are some issues with ansible_fqdn platform fact (#38777, #9972, maybe others). I recently stuck into another one: if you have multiple PTR records with different names for one IP address, ansible_fqdn value is randomly set to one of those names. For example, Mikrotik built-in DNS server lets you have multiple names resolving to the same IP, but it gives you no option to choose which name to resolve that IP into via PTR record — it just creates as many PTRs for that IP as many names you give it. Nevertheless,
Due to this, I propose a new fact, ansible_hostname_f, which value is populated the same way
In order not to break the backwards compatibility with existing setups, I don't replace any existing facts but add new ones instead.
In order to maintain cross-platform portability this implementation does not call hostname(1) binary but implements the same algo on python using the already-utilised socket module.
Please consider applying.