68 lines
1.7 KiB
Plaintext
68 lines
1.7 KiB
Plaintext
|
terminal length default 0
|
||
|
line console
|
||
|
line telnet
|
||
|
line ssh
|
||
|
|
||
|
port-channel load-balance src-dst-ip
|
||
|
|
||
|
ip ssh server
|
||
|
|
||
|
vlan {{ vlans | map(attribute='vid') | compact_numlist }}
|
||
|
|
||
|
{% for iface in interfaces | selectattr('lag') %}
|
||
|
interface {{ iface.name }}
|
||
|
{% if iface.enabled %} no{% endif %} shutdown
|
||
|
channel-group {{ iface.lag.name | select('in', '0123456789') | join('') }} mode active
|
||
|
|
||
|
{% endfor %}
|
||
|
|
||
|
{%- set mgmt = namespace(ip=false, gw=false) %}
|
||
|
{%- for iface in interfaces | rejectattr('lag') %}
|
||
|
interface {{ iface.name }}
|
||
|
{% if iface.type.value != 'lag' %}
|
||
|
{% if iface.enabled %} no shutdown{% else %} shutdown{% endif %}
|
||
|
{% endif %}
|
||
|
|
||
|
{%+ 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 {{ (iface.tagged_vlans or vlans) | map(attribute='vid') | compact_numlist }}
|
||
|
|
||
|
{%+ else %}
|
||
|
|
||
|
{% 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 %}
|
||
|
{% endfor %}
|
||
|
|
||
|
{%- if mgmt.ip %}
|
||
|
interface Vlan1
|
||
|
ip address {{ mgmt.ip | ipaddr('address') }} {{ mgmt.ip | ipaddr('netmask') }}
|
||
|
{% endif %}
|
||
|
|
||
|
snmp-server name {{ inventory_hostname }}
|
||
|
|
||
|
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
|