# Ansible and name resolution

**URL:** <https://forum.ansible.com/t/ansible-and-name-resolution/17560>\
**Category:** Ansible Project\
**Created:** [February 19, 2015, 12:00am UTC](https://forum.ansible.com/t/ansible-and-name-resolution/17560 "2015-02-19T00:00:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Charles\_Brown](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@Charles\_Brown](https://forum.ansible.com/u/Charles_Brown)\
**Post date:** [February 19, 2015, 12:00am UTC](https://forum.ansible.com/t/ansible-and-name-resolution/17560/1 "2015-02-19T00:00:10Z")

</div>

Hello,

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

Thanks.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [February 19, 2015, 8:32am UTC](https://forum.ansible.com/t/ansible-and-name-resolution/17560/2 "2015-02-19T08:32:44Z")

</div>

Using the ‘pipe’ lookup you can use the output of a command, e.g. " dig +short [my.dns.name](http://my.dns.name) "

[http://docs.ansible.com/playbooks\_lookups.html#more-lookups](http://docs.ansible.com/playbooks_lookups.html#more-lookups)

---

<div class="post-metadata">

**Author:** ![Charles\_Brown](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@Charles\_Brown](https://forum.ansible.com/u/Charles_Brown)\
**Post date:** [February 19, 2015, 2:54pm UTC](https://forum.ansible.com/t/ansible-and-name-resolution/17560/3 "2015-02-19T14:54:16Z")

</div>

Apologies for double post. Didn’t realize forum was moderated for first posters.

---

<div class="post-metadata">

**Author:** ![Jan-Piet\_Mens](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@Jan-Piet\_Mens](https://forum.ansible.com/u/Jan-Piet_Mens)\
**Post date:** [February 20, 2015, 5:20pm UTC](https://forum.ansible.com/t/ansible-and-name-resolution/17560/4 "2015-02-20T17:20:15Z")

</div>

> 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] 😉

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP

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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 20, 2015, 5:22pm UTC](https://forum.ansible.com/t/ansible-and-name-resolution/17560/5 "2015-02-20T17:22:03Z")

</div>

nice!

---

<div class="post-metadata">

**Author:** ![Jan-Piet\_Mens](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@Jan-Piet\_Mens](https://forum.ansible.com/u/Jan-Piet_Mens)\
**Post date:** [February 21, 2015, 1:43pm UTC](https://forum.ansible.com/t/ansible-and-name-resolution/17560/6 "2015-02-21T13:43:09Z")

</div>

> nice!

Submitted as PR #10311 [https://github.com/ansible/ansible/pull/10311](https://github.com/ansible/ansible/pull/10311)

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

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

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lookup('dnstxt', 'example.com')

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

I hope that helps.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-JP
