DebugFactor.com | Forum

How to find the FQDN, shortname and IP of linux and windows server using Ansible

You can use the below ones to get these details. Keep in mind that gather_facts: true should be set.

ansible_fqdn
ansible_hostname
ansible_default_ipv4.address

If gather_facts: false then you can use as below. These values are taken from the inventory, unlike the above ones where Ansible finds the values.

inventory_hostname
inventory_hostname_short