Nested variables inside templates

Interfaces are different for every server I’m working with, so to print details of each interface, let’s say I’m using the following code in a template:

interfaces: {% for a_value in ansible_interfaces %}{{ a_value }} {% endfor %}

Now this ends up printing:

interfaces: lo enp0s3 enp0s8

This gives us variables ansible_lo, ansible_enp0s3, ansible_enp0s8 that I want to refer.

Is there any way I can print the value of ansible_lo.value ``using the loop above?

Thanks.

To my knowledge ansible_<interface> doesn't have a key called value, but you can use the content of a key like this

   {{ vars['ansible_' ~ a_value].<key> }}

Thanks! That’s exactly what I wanted!

I mistyped ‘active’ as ‘value’. Not sure what was going on in my head haha.