FreeKB - Ansible inventory_hostname magic variable (managed node hostname)
Ansible - inventory_hostname magic variable (managed node hostname)

Let's say you've a managed node (e.g. target system) with the following hostname.

server1.example.com

 

The inventory_hostname magic variable will return the full hostname, like this.

server1.example.com

 

The inventory_hostname_short magic variable will return only the short hostname, like this.

server1

 

For example, let's say you have the following.

- debug
    msg: full hostname is {{ inventory_hostname }}

- debug
    msg: short hostname is {{ inventory_hostname_short }}

 

Running this playbook should return the following.

TASK [debug]
ok: [server1.example.com] => {
    "msg: "full hostname is server1.example.com"
}

TASK [debug]
ok: [server1.example.com] => {
    "msg: "short hostname is server1"
}

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 171c0 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |