Iterate over complex dicitonary structure in j2 tempalte

Sorry if this has been documented elsewhere (where?), but how can one iterate with jinja2 over a dictionary?

http://stackoverflow.com/questions/33666820/ansible-jinja2-loops-over-complex-structures

You can ask here or in stackoverflow.

Thanks

Hi,

this may help:
https://docs.ansible.com/ansible/playbooks_loops.html#looping-over-subelements

https://docs.ansible.com/ansible/playbooks_loops.html#looping-over-hashes

Alex

I saw those, but they do not apply to jinja2 templates.

/Hristo Stoyanov

The jinja2 templates documentation contains multiple examples of looping over dictionaries:

http://jinja.pocoo.org/docs/dev/templates/#for

Using ‘.iteritems()’, or ‘.items()’ as well as using the ‘|dictsort’ filter