I&#x27;d agree that jinja2 has a perfectly fine way of handling loops, but the problem is that functionality only works in Ansible template files.
The Ansible playbook can only make use jinja2 filters to act on variables:
<a href="https:&#x2F;&#x2F;docs.ansible.com&#x2F;ansible&#x2F;playbooks_filters.html" rel="nofollow">https:&#x2F;&#x2F;docs.ansible.com&#x2F;ansible&#x2F;playbooks_filters.html</a>