access: move switch config templates back to this repo
Let’s keep it simple. Also editing templates in NetBox is a pain.
This commit is contained in:
parent
1ffdea8e43
commit
c479f90669
7 changed files with 128 additions and 11 deletions
41
roles/access/templates/config-fs.j2
Normal file
41
roles/access/templates/config-fs.j2
Normal file
|
@ -0,0 +1,41 @@
|
|||
hostname {{ inventory_hostname }}
|
||||
|
||||
no netconf enable
|
||||
|
||||
no enable service telnet-server
|
||||
no enable service web-server http
|
||||
no enable service web-server https
|
||||
|
||||
vlan range {{ vlans | map(attribute='vid') | union([1]) | compact_numlist }}
|
||||
|
||||
{% for iface in interfaces %}
|
||||
interface {{ iface.name }}
|
||||
{% if iface.enabled %} no{% endif %} shutdown
|
||||
{% if iface.lag %}
|
||||
port-group {{ iface.lag.name | select('in', '0123456789') | join('') }} mode active
|
||||
|
||||
{% elif iface.mgmt_only %}
|
||||
{% if iface.ip_addresses %}
|
||||
{% set address = iface.ip_addresses | map(attribute='address') | first %}
|
||||
ip address {{ address | ipaddr('address') }} {{ address | ipaddr('netmask') }}
|
||||
{% if iface.custom_fields.gateway %}
|
||||
gateway {{ iface.custom_fields.gateway.address | ipaddr('address') }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
|
||||
{% else %}
|
||||
mtu {{ iface.mtu | default('9216', true) }}
|
||||
{% 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 }}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
Loading…
Add table
Add a link
Reference in a new issue