On 27. aug. 2016 05:20, Lupin Deterd wrote:
Hi,
I want to gather all the NICs and its IP address from facts. So I tried
iterating to all interfaces, i.e
{% for nic in ansible_interfaces %}
{% set present_nic = 'facter_ipaddress_%s' | format( nic ) %}
| {{ nic }} | {{ present_nic }} |
{% endfor %}
The present_nic variable turn into some form of string and won't evaluate
object anymore. :(
I wanted to grab the value of 'facter_ipaddress_{{ nic }} key, but instead
got a literal string.
| *NIC* | *IP* | *Netmask* |
| lo | facter_ipaddress_lo |
| enp0s3 | facter_ipaddress_enp0s3 |
| enp0s8 | facter_ipaddress_enp0s8 |
Is there a way to get around with this, without resorting to writing a
custom facts/module?
{% for nic in ansible_interfaces %}
| {{ nic }} | {{ hostvars[inventory_hostname]['facter_ipaddress_' + nic]
}} |
{% endfor %}
--
Kai Stian Olstad
--
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/1e715278-620b-9f25-408b-b91fc9c2dfe0%40olstad.com.
For more options, visit https://groups.google.com/d/optout.