This is my Bonding.yml
---
- name: Configure team interface
hosts: vhost3
user: root
vars:
network_connections:
- name: bond0
state: up
type: bond
interface_name: bond0
mtu: 9000
- name: bond0-ens2f0
state: up
type: ethernet
interface_name: ens2f0
master: bond0
- name: bond0-ens2f1
state: up
type: ethernet
interface_name: ens2f1
master: bond0
- name: bond0.121
state: up
type: vlan
parent: bond0
vlan:
id: 121
interface_name: bond0.121
ip:
address:
- 10.1.xx.xxx/24
mtu: 9000
And with this tasks I can filter and list the interfaces with 25Gbit speed.
- name: Show the result 3
set_fact:
filter_interfaces: "{{interfaces_per_speed | selectattr('speed', '==', 25000) | list }}"
- name: Show the result 4
debug:
msg: "{{filter_interfaces[0].interfaces}}"
How can I do, so instead of saying example interface_name: ens2f0, it automatically recognizes and chooses interfaces with 25Gbit?