69 lines
1.6 KiB
Django/Jinja
69 lines
1.6 KiB
Django/Jinja
terminal length default 0
|
|
!
|
|
line console
|
|
!
|
|
line telnet
|
|
!
|
|
line ssh
|
|
!
|
|
port-channel load-balance src-dst-ip
|
|
!
|
|
ip ssh server
|
|
ssh user admin authentication-method publickey /c:/ansible.pub
|
|
!
|
|
vlan {{ vlans | map(attribute='vid') | vlan_parser | join(',') }}
|
|
!
|
|
{% for iface in interfaces | selectattr('enabled') | selectattr('lag') %}
|
|
interface {{ iface.name }}
|
|
channel-group 1 mode active
|
|
!
|
|
{% endfor %}
|
|
{% set mgmt = namespace(ip=false, gw=false) %}
|
|
{% for iface in interfaces | rejectattr('lag') %}
|
|
interface {{ iface.name }}
|
|
{% if iface.enabled and iface.mode %}
|
|
{% if iface.type.value != 'lag' %}
|
|
no shutdown
|
|
{% endif %}
|
|
{% if iface.mgmt_only and iface.ip_addresses %}
|
|
{% set mgmt.ip = iface.ip_addresses[0].address %}
|
|
{% if iface.custom_fields.gateway %}
|
|
{% set mgmt.gw = iface.custom_fields.gateway.address %}
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if 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.value == 'tagged' %}
|
|
switchport mode trunk
|
|
switchport trunk allowed vlan {{ (iface.tagged_vlans or vlans) | map(attribute='vid') | vlan_parser | join(',') }}
|
|
{% endif %}
|
|
{% else %}
|
|
shutdown
|
|
{% endif %}
|
|
!
|
|
{% endfor %}
|
|
{% if mgmt.ip %}
|
|
interface Vlan1
|
|
ip address {{ mgmt.ip | ipaddr('address') }} {{ mgmt.ip | ipaddr('netmask') }}
|
|
{% endif %}
|
|
!
|
|
sntp enable
|
|
{% for address in ntp %}
|
|
sntp server {{ address }}
|
|
{% endfor %}
|
|
!
|
|
ntp access-group default nomodify noquery
|
|
!
|
|
{% if mgmt.gw %}
|
|
ip route 0.0.0.0 0.0.0.0 {{ mgmt.gw | ipaddr('address') }} primary
|
|
{% endif %}
|
|
!
|
|
no ddp
|
|
!
|
|
end
|