network/roles/access/templates/config-fs-s5800-48t4s.j2

56 lines
1.6 KiB
Django/Jinja

hostname {{ inventory_hostname }}
service http disable
service telnet disable
vlan database
{% for vlan in add_vlans %}
vlan {{ vlan }}
{% endfor %}
{% for vlan in del_vlans %}
no vlan {{ vlan }}
{% endfor %}
exit
{# sort to ensure LAG interfaces are added last #}
{% for iface in interfaces | sort(attribute="type.value") | sort(attribute="mgmt_only") %}
{% if iface.mgmt_only %}
{% for address in iface.ip_addresses %}
{% set subnet = address.address | ipaddr('subnet') %}
{% set prefix = prefixes | selectattr('prefix', '==', subnet) | first %}
{% if address.family.value == 4 %}
management ip address {{ address.address }}
{% if prefix.custom_fields.gateway %}
management route add gateway {{ prefix.custom_fields.gateway.address | ipaddr('address') }}
{% endif %}
{% else %}
management ipv6 address {{ address.address }}
{% endif %}
{% endfor %}
{% else %}
interface {{ iface.name }}
{% if iface.enabled %} no{% endif %} shutdown
{% if iface.lag %}
channel-group {{ iface.lag.name | select('in', '0123456789') | join('') }} mode active
{% else %}
{% if iface.mode and iface.mode.value == 'access' %}
switchport mode access
{% if iface.untagged_vlan and iface.untagged_vlan.vid != 1 %}
switchport access vlan {{ iface.untagged_vlan.vid }}
{% else %}
no switchport access vlan
{% endif %}
{%- elif iface.mode and iface.mode.value == 'tagged' %}
switchport mode trunk
switchport trunk allowed vlan only {{ (iface.tagged_vlans or vlans) | map(attribute='vid') | compact_numlist }}
{%- elif iface.mode and iface.mode.value == 'tagged-all' %}
switchport mode trunk
switchport trunk allowed vlan all
{% endif %}
{% endif %}
{% endif %}
{% endfor %}