On Wed, 18 Feb 2015 15:15 -0800, Charles Brown <[email protected]>
wrote:
> Hello,
>
> Given a list of hostnames, how would I resolve the names to IP address
> for
> use in a Jinja2 template? I don't see a Jinja filter that performs
> gethostbyname lookups, and I don't see a way to do this in Ansible
> either.
I don't think there is a lookup plugin for that, yet.
Not the cleanest way, but you could use register and dig:
vars:
some_ip: "8.8.8.8"
some_hostname: "google.com"
tasks:
- name: resolve some ip
command: "dig +short -x {{ some_ip }}"
register: resolved_ip
- debug:
var: resolved_ip.stdout
- name: resolve some hostname
command: "dig +short {{ some_hostname }}"
register: resolved_hostname
- debug:
var: resolved_hostname.stdout
Giovanni
--
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/1424308347.3929224.229484697.18028B0D%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.