network/roles/fabric/templates/bond.intf.j2

24 lines
1 KiB
Plaintext
Raw Normal View History

2023-12-18 10:22:14 +00:00
{% for bond in interfaces | map(attribute='lag') | reject('none') | sort(attribute='name') | unique %}
{% set iface = interfaces | selectattr('id', '==', bond.id) | first %}
{% set members = interfaces | selectattr('lag') | selectattr('lag.name', '==', bond.name) -%}
auto {{ bond.name }}
iface {{ bond.name }}
bond-slaves {{ members | map(attribute='name') | join(' ') }}
{% if iface.mode.value == 'access' and iface.untagged_vlan %}
bridge-access {{ iface.untagged_vlan.vid }}
{% elif iface.mode.value == 'tagged' and iface.tagged_vlans %}
bridge-vids {{ iface.tagged_vlans | map(attribute='vid') | join(' ') }}
{% endif %}
{#- If the peer shares a bond with the same name, generate a clag-id for it unless the bonded link is to peer itself. #}
{% if peer %}
{% set peer_members = hostvars[peer].interfaces
| selectattr('lag') | selectattr('lag.name', '==', bond.name) %}
{% if peer_members | iface_peer | reject('eq', inventory_hostname) %}
clag-id {{ (members + peer_members) | cl_clag_id }}
{% endif %}
{% endif %}
{% endfor %}