Tag Archives: jinja

Ansible – loop over netsted variables

I’ve started using Ansible at my work, where we use it to deploy Splunk environments.

One of the things I needed to do is to provide a list of tcp ports to a “with_items” statement in a form of list.

I have this vars file and I needed to filter out only the TCP ports

So here is how you can do it (in 2 steps) in Ansible.

Of course you can replace the debug msg with whatever other action you need.
By the way if you know how to do it in single step please let me know.