45 lines
1.5 KiB
Django/Jinja
45 lines
1.5 KiB
Django/Jinja
{% for iface in interfaces | rejectattr('name', 'in', ('lo', 'bridge')) | rejectattr('mgmt_only') | selectattr('enabled') %}
|
|
auto {{ iface.name }}
|
|
iface {{ iface.name }}
|
|
{% if iface.vrf %}
|
|
vrf {{ iface.vrf.name }}
|
|
{% endif -%}
|
|
|
|
{% if iface.mtu %}
|
|
mtu {{ iface.mtu }}
|
|
{% endif -%}
|
|
|
|
{% if iface.type.value == 'lag' %}
|
|
{#- Bond/MLAG stuff. #}
|
|
{% set members = interfaces | selectattr('lag') | selectattr('lag.name', '==', iface.name) %}
|
|
{% if members %}
|
|
bond-slaves {{ members | map(attribute='name') | join(' ') }}
|
|
{% endif %}
|
|
{% if iface.custom_fields.bond_mode %}
|
|
bond-mode {{ iface.custom_fields.bond_mode }}
|
|
{% 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 is defined %}
|
|
{% set peer_members = hostvars[peer].interfaces | selectattr('lag') | selectattr('lag.name', '==', iface.name) %}
|
|
{% if peer_members | iface_peer | reject('eq', inventory_hostname) %}
|
|
clag-id {{ (members + peer_members) | cl_clag_id }}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{#- Set allowed VLANs if we are part of the bridge. #}
|
|
{% if iface.bridge and iface.mode %}
|
|
{% 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 %}
|
|
{% endif %}
|
|
|
|
{#- Addresses. #}
|
|
{% for addr in iface.ip_addresses %}
|
|
address {{ addr.address }}
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|