Bonding with ansible

I already know hot to bond to interfaces with ansible. But here is were it gets complicated: I need to make a playbook that lists all the facts, filtering just the interfaces, classifying them by speed and bonding them automatically.
The idea would be to start with something like this, but I’m completely lost.

  • hosts: pve1 remote_user: root tasks:
    • name: print interfaces debug: msg: “{{ ansible_facts | dict2items | selectattr(‘value.speed’, ‘defined’) | map(attribute=‘value’) | list}}”

If someone knows and explains me how to do it, it would be very nice

If you show what the current data structure exactly looks like, and
how this ties into what you want your system to look like, then we
might be able to help.
(i'm only vaguely familiar with the network interface stuff...)