get item from nested loop item

Hi,

I have list of items in configuration files as variable

hostenv:

  • env: test
    Serverconf:
    Resource:
  • mem:
    Interface:
  • { name: eth0, address: 10.0.10.2}
  • {eth1: …}

Now, I would like to fetch and print the values from interface {{ item.address }}

I tried to loop multiple usecase, but failed with object undefined error

Playbook:
task:

  • debug:
    msg: {{ item.address }}
    loop: {{ hostenv.Serverconf.Interface }}
    loop_var: item

Thanks

It’s hard to tell from this platform’s poor support of indentation, but it appears “hostenv” is a list. Try
loop: “{{ hostenv[0].Serverconf.Interface }}”