# fqdn for all host interfaces

**URL:** <https://forum.ansible.com/t/fqdn-for-all-host-interfaces/16843>\
**Category:** Ansible Project\
**Created:** [November 21, 2014, 3:14pm UTC](https://forum.ansible.com/t/fqdn-for-all-host-interfaces/16843 "2014-11-21T15:14:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [November 21, 2014, 3:14pm UTC](https://forum.ansible.com/t/fqdn-for-all-host-interfaces/16843/1 "2014-11-21T15:14:56Z")

</div>

Hi,

I have a 3 tier setup, web, app and db.

Each tier has a mgmt, upper and lower network interface

I need to add the fqdn for the lower app interface in the hosts.equiv on the db server

I was doing this with IP which worked fine using

{{ hostvars[host][informix\_interface][‘ipv4’][‘address’] }} {{ db\_user }}

but need to change to use fqdn. This isn’t in the facts.

If I run

> dig -x 192.168.24.12 +short  
> [test-boapp-02.lower.foo.com](http://test-boapp-02.lower.foo.com).

I get the name i’m looking for. Just wondering how I could go about using it. As currently its in a loop in a template.

Can you set variables from commands in jinja2 templates?

Any help appreciated. I could semi hack it since I could use variables for the interface name and the domain and just build up the correct string

James

---

<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:** [November 21, 2014, 3:23pm UTC](https://forum.ansible.com/t/fqdn-for-all-host-interfaces/16843/2 "2014-11-21T15:23:44Z")

</div>

shell: dig...  
register: digoutput  
now the digoutput variable has the output of dig

---

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [November 21, 2014, 3:44pm UTC](https://forum.ansible.com/t/fqdn-for-all-host-interfaces/16843/3 "2014-11-21T15:44:41Z")

</div>

Hi,

Thanks though this is in a loop inside the templates. I have many hosts

I was thinking of building up a dictionary in the playbook for each host.

Was a little unsure how to build that up

---

<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:** [November 21, 2014, 3:57pm UTC](https://forum.ansible.com/t/fqdn-for-all-host-interfaces/16843/4 "2014-11-21T15:57:08Z")

</div>

you can use set\_fact for each host before calling the template

---

<div class="post-metadata">

**Author:** ![James\_Morgan1](https://avatars.discourse-cdn.com/v4/letter/j/57b2e6/32.png) [@James\_Morgan1](https://forum.ansible.com/u/James_Morgan1)\
**Post date:** [November 21, 2014, 4:47pm UTC](https://forum.ansible.com/t/fqdn-for-all-host-interfaces/16843/5 "2014-11-21T16:47:30Z")

</div>

Thanks,

will give that a go
