Hi Sergey, I see, in that case try pipe lookup plugin: http://docs.ansible.com/ansible/playbooks_lookups.html#more-lookups
And try to resolve IP address from hostname by some cmdline resolver. David Karban Linux server specialist/Specialista na správu linuxových serverů www.karban.eu 2015-09-01 6:36 GMT+02:00 Sergey Maslyakov <[email protected]>: > Hi David, > > Thank you very much for your response! > > My understanding is that this solution requires that Ansible "visits" the > remote host to get the list of interfaces and their settings, including the > IPv4 address for each interface. For example, I would not be able to use it > to resolve "www.google.com" or any other arbitrary string, right? > > > Cheers, > /Sergey > > On Monday, August 31, 2015 at 11:18:55 PM UTC-5, David Karban wrote: >> >> Hi Sergey, >> >> you can try something like: >> {% for host in groups['app_servers'] %} >> ACCEPT $FW int:{{ hostvars[host]['ansible_eth1']['ipv4']['address'] >> }} tcp 80,443 >> {% endfor %} >> >> Key think is hostvars variable. >> >> David Karban >> Linux server specialist/Specialista na správu linuxových serverů >> www.karban.eu >> >> 2015-09-01 6:04 GMT+02:00 Sergey Maslyakov <[email protected]>: >> >>> What is the right way to look up the IPv4 address (or addresses) >>> associated with a host name from global_vars? >>> >>> Here is the scenario. I use Postgres with Host-Based Authentication >>> (HBA). In order to configure HBA, I need to put* IP addresses* of the >>> permitted clients into the configuration file, but what I have as the input >>> are *host FQDNs* that I need to resolve somehow. What would be the best >>> way to do it in a Jinja2 template or within group_vars? >>> >>> I tried to use Python socket.gethostbyname() but I could not get the >>> syntax right. >>> >>> Granted, I can fall back to a shell script and templetize it outside of >>> Ansible/Jinja2 but I still hope to find a decent way to do it in Ansible. >>> >>> >>> Regards, >>> /Sergey >>> >>> -- >>> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/5bd52a9d-e30a-46cc-808a-7f1237c1294b%40googlegroups.com >>> <https://groups.google.com/d/msgid/ansible-project/5bd52a9d-e30a-46cc-808a-7f1237c1294b%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- > 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 [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/38e01b38-35d3-4f83-af68-3bba1f57579f%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/38e01b38-35d3-4f83-af68-3bba1f57579f%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAOBFM96aNnVMWz7qS1ozjKyrxCuF%3D%3DiWHXN3U0jYsCC0HZjQQg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
