Member-only story
Ansible terminology — ansible_hostname vs inventory_hostname vs ansible_fqdn
What is the difference between ansible_hostname vs inventory_hostname vs ansible_fqdn in a practical example with Ansible Playbook?
4 min readMar 11, 2022
What is the difference between ansible_hostname vs inventory_hostname?
These two ansible internal variables sometimes confuse one for another but they’re fundamentally different.
I’m Luca Berton and welcome to today’s episode of Ansible Pilot.
ansible_hostname vs inventory_hostname
ansible_hostname and ansible_fqdn
Read from the target machine hostname from the facts:
- `
ansible_hostname
` read the hostname from the facts collected during the `gather_facts
` - same as the `
uname -n
` or `hostname
` command-line - Need `
gather_facts
` enabled, otherwise the `ansible_facts
` variable would be unavailable to use in your playbook - Same as hostname of the target host