Member-only story

Demystifying 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?

Luca Berton
4 min readDec 9, 2023

Introduction

Understanding Ansible’s internal variables is crucial for effective playbook creation. In today’s episode of Ansible Pilot, I’m Luca Berton, and we’ll unravel the differences between ansible_hostname, inventory_hostname, and ansible_fqdn with practical examples in Ansible Playbooks.

Decoding the Terminology

ansible_hostname and ansible_fqdn

ansible_hostname reads the hostname from the facts collected during the gather_facts step. It is equivalent to running uname -n or the hostname command-line on the target machine. Importantly, it requires gather_facts to be enabled in your playbook for the variable to be available. This variable reflects the hostname of the target host.

ansible_fqdn also gathers information during gather_facts but specifically retrieves the fully qualified domain name (FQDN) of the…

--

--

Luca Berton
Luca Berton

Written by Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday

No responses yet