Just as a reference point. It appears that what this charm helper *really* wants to do is get the host's "default" IP address. Recognizing that a reverse name lookup is a rather poor way of finding that out, Ansible does an ip route get to two well-known IP addresses (v4 and v6) to determine the outgoing interface for the default route, and then returns that interface's address as ansible_default_ipv4.address, and ansible_default_ipv6.address.
Just as a reference point. It appears that what this charm helper *really* wants to do is get the host's "default" IP address. Recognizing that a reverse name lookup is a rather poor way of finding that out, Ansible does an ip route get to two well-known IP addresses (v4 and v6) to determine the outgoing interface for the default route, and then returns that interface's address as ansible_ default_ ipv4.address, and ansible_ default_ ipv6.address.
See https:/ /github. com/ansible/ ansible/ blob/devel/ lib/ansible/ module_ utils/facts. py#L1918 for details.