I'm trying to dynamically set /etc/hosts based on the ipv4 address assigned
to all the interfaces on a host... my template reads as such
127.0.0.1 localhost.localdomain localhost
{% for item in ansible_interfaces if item != 'lo' %}
{{ 'ansible_' + item + '.ipv4.address' }} {{ lookup('dig', 'ansible_' +
item + '.ipv4.address' + '/PTR') }}
{% endfor %}
which results in :
127.0.0.1 localhost.localdomain localhost
ansible_eth1.ipv4.address NXDOMAIN
ansible_eth0.ipv4.address NXDOMAIN
I've tried several iterations, but I'm struggling to find the proper syntax
to get the file to write as expected... is this possible? Any suggestions
greatly appreciated.
--
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/abeeffdc-5c60-4ab0-986b-15e72e23922f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.