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 }}"
On Wednesday, November 1, 2023 at 9:35:35 AM UTC-4 Vaishnave M wrote:
> 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
>
>
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/cfcfb851-46f7-4797-a12e-cce493e6a615n%40googlegroups.com.