Hi,
I try to search the doc and the list to see if it is possible to use the inventory hostname in playbooks (the one specified in /etc/ansible/hosts).
Because in case the name in the inventory doesn’t match the remote hostname (/etc/hosts, cname, etc.), the setup module isn’t reporting any ansible variable with this info.
Did I miss something ?
Julien.
There's a "magic" variable called $inventory_hostname that matches the
name given in the inventory file, that I think is what you want.
I'm not sure where it is on the docs but the two varibles you get
automatically are
$inventory_hostname
and
$inventory_hostname_short
The latter being everything up to the first '.' in $inventory_hostname
Great !
Exactly what I was looking for.
And, it is mentioned in the docs in the following section.
http://ansible.cc/docs/playbooks2.html?highlight=inventory_hostname#contents
So all is good.
Thank you.