fqdn for all host interfaces

44 views
Skip to first unread message

James Morgan

unread,
Nov 21, 2014, 10:14:56 AM11/21/14
to ansible...@googlegroups.com
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

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

Brian Coca

unread,
Nov 21, 2014, 10:23:46 AM11/21/14
to ansible...@googlegroups.com
shell: dig...
register: digoutput
now the digoutput variable has the output of dig

James Morgan

unread,
Nov 21, 2014, 10:44:41 AM11/21/14
to ansible...@googlegroups.com
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

Brian Coca

unread,
Nov 21, 2014, 10:57:11 AM11/21/14
to ansible...@googlegroups.com
you can use set_fact for each host before calling the template
> --
> 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/f6f30f58-10e8-42a4-891f-5e40262e94c3%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

James Morgan

unread,
Nov 21, 2014, 11:47:30 AM11/21/14
to ansible...@googlegroups.com
Thanks,

will give that a go
Reply all
Reply to author
Forward
0 new messages