Skip to content

How to associate interfaces to LAGs using Ansible facts #1134

Answered by gpipito
gpipito asked this question in Q&A
Discussion options

You must be logged in to vote

I found a workaround:

  1. I create a list of physical interfaces
  2. then a list of bonds/lags
  3. I combine interfaces and bonds in a new dict when interface name is contained in the bond slaves field
  4. I update interfaces in netbox associating the bond
      - name: Create List - Interfaces
        set_fact:
          nb_interfaces: "{{ nb_interfaces|default([]) + [item] }}"
        with_items: "{{ ansible_facts.interfaces }}"
        when: >
          ansible_facts[item].module is defined and 
          ansible_facts[item].slaves is not defined

      - name: Create List - Bonds
        set_fact:
          nb_bonds: "{{ nb_bonds|default([]) + [item] }}"
        with_items: "{{ ansible_facts.interf…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by gpipito
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant