It might be easier to munge the data structure into a more appropriate format first and then use the munged data in subsequent tasks. Wondering how to do it? Here’s a short step-by-step guide.
If this trick was all you were looking for I hope you’ll find it useful. If you’re looking for a bigger picture, start with Ansible for Networking Engineers webinar, explore other network automation webinars and register for the Building Network Automation Solutions online course.