Ansible Bonding with automatic recongition of interfaces

100 views
Skip to first unread message

bmc1...@gmail.com

unread,
Mar 29, 2021, 4:16:12 AM3/29/21
to Ansible Project

I have some issues with my project. I need to bond two interfaces, automatically choosing the two with 25Gbit speed. I'm able to make a normal bonding selecting the interface names, I'm able to filter the interfaces through speed too, but I'm lost trying to connect both ideas.

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?

Dick Visser

unread,
Mar 29, 2021, 4:52:27 AM3/29/21
to ansible...@googlegroups.com
Where does interfaces_per_speed come from?
Can you post all the data/vars/etc?
> --
> You received this message because you are subscribed to the Google Groups "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6b2a0530-de84-4d65-bd52-d70ca98ff651n%40googlegroups.com.



--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages