connect without dns or /etc/hosts" resolution

i have a dynamic inventory script which outputs the following.

`
“NODE_A”: {
“inventory_hostname”: “10.0.2.6”,
“inventory_lparname”: “NODE_A”
}

`

the nodes are not resolvable via dns or something as this network is some kind of isolated “management” lan.

until now i had a play running which modifies the local /etc/hosts file to enable name resolution. as the ansible controller is going to move to an foreign machine, this is not possible anymore.

so the big question is how to proceed. how do i instruct ansible to connect to the ip adress instead of the hostname repectively can i use inventory_hostname instead of ansible_hostname as connection string, but keep the hostname displayed in the play recap?

chris

You need to use the special variable called ansible_host to indicate the IP address of the host, instead of using inventory_hostname.

inventory_hostname is an internally calculated variable, as such Ansible doesn’t use it from any external source.