Skip to content

Use dns instead of blank ips for ansible_host

The inventory script set the ansible_host variable which indicates how ansible connects to the remote host to a blank ip address described in the hosts hostvars (network.INTERFACE.{ipv4,ipv6}). This is unfortunate because it causes conflicts on systems which do not have an ipv6 (inventory default if remote host has dual stack) or with ssh configurations (e.g. must add the ip to Host field).

So with this commit the inventory does not create the ansible_host variable for each host in hostvars anymore. This is moved into ansible space.

In the 'all' group_vars ansible_host ist set to "{{ inventory_hostname }}.{{ net.domain }}". Due to the overwrite of the net.domain field in some group_vars like irb the dns name will still be evaluated properly.

In cases where this procedure would lead to errors (e.g. host is only accessible via ip, host has different fqdn) it is possible to overwrite the ansible_host variable by simply setting it in the host_vars explicitly.

Merge request reports