I know the conventional way of using Ansible is copying the ssh key on to the target and then adding the ip address to the inventory file. In my case I will not know the Ip address of the target that am testing on, how can ansible get me the ip address? Any workaround
Thanks in advance
Thanks,
Anirudh Vasudevan
I know the conventional way of using Ansible is copying the ssh key on to
the target and then adding the ip address to the inventory file.
I don't agree in this statement, I use hostname and username/password.
In my case
I will not know the Ip address of the target that am testing on, how can
ansible get me the ip address? Any workaround
DNS?
Thanks for the reply.
No what I meant was how can you make ansible talk to a target host without ansible host file not hard coding with the ip address, am newbie to ansible. Apologizes if this seems straightforward.
Thanks,
Anirudh Vasudevan
Yes, that was what i tried to say.
You don't have to use the IP in the inventory file, you can use the hostname, Ansible do use DNS to do lookup.
If that do not answer your question you need to provide us with a lot more information about you setup.
It's hard to give details because you haven't explained why you don't
know the IP.
I've used multicast DNS (via avahi ) on DHCP booted Raspberry Pis to
advertise hostnames, then
put those hostnames into groups in flat file inventories.
That means the servers can change IP without having to update any
config on the ansible node.
You're copying this key up so you'll need some way to find the server, right?
Ansible inventories can be scripts as well as flat files (that's how
things like it's cloud support
works). There's lots of information at:
http://docs.ansible.com/ansible/intro_dynamic_inventory.html