Can Ipaddress of the target be fetched by ansible?
120 views
Skip to first unread message
anirudh vasudevan
unread,
Nov 11, 2016, 12:55:27 PM11/11/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
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
Kai Stian Olstad
unread,
Nov 11, 2016, 4:20:41 PM11/11/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
On 11. nov. 2016 18:30, anirudh vasudevan wrote:
> 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?
--
Kai Stian Olstad
anirudh vasudevan
unread,
Nov 11, 2016, 5:52:48 PM11/11/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project, ansible-pr...@olstad.com
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
Kai Stian Olstad
unread,
Nov 11, 2016, 6:05:09 PM11/11/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible...@googlegroups.com
On 11. nov. 2016 23:52, anirudh vasudevan wrote:
> 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.
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.
--
Kai Stian Olstad
Dick Davies
unread,
Nov 12, 2016, 6:16:04 AM11/12/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ansible list
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: