connect without dns or /etc/hosts" resolution

12 views
Skip to first unread message

christia...@itsv.at

unread,
May 7, 2019, 5:14:56 AM5/7/19
to Ansible Project

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

Matt Martz

unread,
May 7, 2019, 10:12:19 AM5/7/19
to ansible...@googlegroups.com
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a43bbe88-1948-4a0f-9ec3-8fec7f5d0d0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages