Ansible and name resolution

459 views
Skip to first unread message

Charles Brown

unread,
Feb 18, 2015, 7:00:10 PM2/18/15
to ansible...@googlegroups.com
Hello,

How do I perform name-to-IP lookups form within ansible YAML?  Or even better, a Jinja template?

Thanks.

Serge van Ginderachter

unread,
Feb 19, 2015, 3:33:08 AM2/19/15
to ansible...@googlegroups.com
Using the 'pipe' lookup you can use the output of a command, e.g. " dig +short my.dns.name "

http://docs.ansible.com/playbooks_lookups.html#more-lookups

--
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/4c834f70-058b-4b03-98c6-76e4281ba0f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Charles Brown

unread,
Feb 19, 2015, 9:54:22 AM2/19/15
to ansible...@googlegroups.com
Apologies for double post.  Didn't realize forum was moderated for first posters.

Jan-Piet Mens

unread,
Feb 20, 2015, 12:20:28 PM2/20/15
to ansible...@googlegroups.com
> Using the 'pipe' lookup you can use the output of a command, e.g. " dig
> +short my.dns.name "

Charles' question, and Serge's response prompted me to finally get
something done about this. Test at your own risk. [1] ;-)

-JP

[1] http://jpmens.net/2015/02/20/a-new-dns-lookup-plugin-for-ansible/

Brian Coca

unread,
Feb 20, 2015, 12:23:34 PM2/20/15
to ansible...@googlegroups.com
nice!




--
Brian Coca

Jan-Piet Mens

unread,
Feb 21, 2015, 8:43:19 AM2/21/15
to ansible...@googlegroups.com
> nice!

Submitted as PR #10311 https://github.com/ansible/ansible/pull/10311

IMO, dnstxt.py should be removed, and the docs updated to say

Users of the previously-available `dnstxt` lookup-plugin should
migrate to `dig` by changing

lookup('dnstxt', 'example.com')

to
lookup('dig', 'example.com/TXT')

I hope that helps.

-JP
Reply all
Reply to author
Forward
0 new messages