This repository has been archived by the owner on Apr 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathswitch.j2
203 lines (202 loc) · 6.08 KB
/
switch.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
enable
!
configure terminal
!
{% if timezone %}
clock timezone {{ timezone }}
{% else %}
clock timezone UTC
{% endif %}
!
hostname {{ hostname }}
!
{%if no_domain_lookup %}
no ip domain lookup
{%endif%}
{% if domain_name %}
ip domain name {{ domain_name }}
{% endif %}
!
{% if vtp.status %}
vtp domain {{ vtp.domain_name }}
vtp version {{ vtp.version }}
vtp mode {{ vtp.mode }}
{% else %}
vtp mode transparent
{% endif %}
!
{% if stp_mode %}
spanning-tree mode {{ stp_mode }}
{% else %}
spanning-tree mode pvst
{% endif %}
!
logging console {{ logging }}
logging buffered {{ logging_buffer_size }}
!
diagnostic bootup level {{ diagnostic_level }}
!
{% if license_level.advantage %}
license boot level network-advantage {% if license_level.addon %}addon dna-advantage {% endif %}
{% endif %}
{% if lldp %}
!
lldp run
{% endif %}
!
{% if crypto.status %}
crypto key generate rsa general-keys modulus {{ crypto.key_size }}
ip ssh version {{ crypto.ssh_version }}
{% endif %}
!
{% for user in users %}
username {{ user.username }} privilege {{ user.privilege_level }} algorithm-type {{ user.algorithm_type }} secret {{ user.password }}
{% endfor %}
{% if enable_secret.status %}
enable algorithm-type scrypt secret {{ enable_secret.password }}
{% endif %}
!
{% if http_server == false %}
no ip http server
no ip http secure-server
{% else %}
ip http server
ip http secure-server
{% endif %}
!
{% if errdisable.status %}
errdisable recovery cause {{ errdisable.recovery_cause }}
errdisable recovery interval {{ errdisable.recovery_interval }}
!
{% endif %}
banner motd $
#################** D I S C L A I M E R **##################
# #
# UNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED #
# #
# Restricted to authorized individuals ONLY. #
# #
# You MUST have explicit, authorized permission to #
# access or configure this device. #
# #
# All activities performed on this device are logged, #
# monitored, and recorded. #
# #
# Unauthorized attempts and actions to access, modify #
# or use this system may result in civil and/or criminal #
# penalties. #
# #
# Disconnect IMMEDIATELY if you are not an authorized #
# user. #
# #
############################################################
$
!
{% for vlan in vlans %}
vlan {{ vlan.id }}
name {{ vlan.name }}
exit
!
{% endfor %}
interface Vlan 1
no ip address
shutdown
exit
!
{% for interface_vlan in interface_vlans %}
interface Vlan {{ interface_vlan.id }}
ip address {{ interface_vlan.ip_addr }} {{ interface_vlan.mask }}
description {{ interface_vlan.name }}
no shutdown
exit
!
{% endfor %}
{% for etherchannel in etherchannels %}
interface port-channel {{ etherchannel.id }}
{% if etherchannel.trunk %}
switchport mode trunk
description {{ etherchannel.description }}
{% if etherchannel.native_vlan.status %}
switchport trunk native vlan {{ etherchannel.native_vlan.id }}
{% endif %}
{% else %}
switchport mode access
{% endif %}
exit
!
{% endfor %}
{% if mgmt_interface.status %}
interface GigabitEthernet0/0
ip address {{ mgmt_interface.ip_addr }} {{ mgmt_interface.mask }}
vrf forwarding Mgmt-vrf
description Management Interface
no shutdown
exit
!
{% endif %}
{% for interface in interfaces %}
interface range {{ interface.interface_name }} {{ interface.switch_number }}/{{ interface.module_number }}/{{ interface.id_range }}
switchport mode {{ interface.type }}
switchport access vlan {{ interface.access_vlan }}
{% if interface.voice_vlan %}
switchport voice vlan {{ interface.voice_vlan }}
{% endif %}
{% if interface.portfast %}
spanning-tree portfast
{% endif %}
{% if interface.bpduguard %}
spanning-tree bpduguard enable
{% endif %}
{% if interface.port_security.status %}
switchport port-security
switchport port-security mac-address sticky
switchport port-security maximum {{ interface.port_security.maximum }}
switchport port-security violation {{ interface.port_security.violation }}
{% endif %}
description {{ interface.description }}
exit
!
{% endfor %}
{% for uplink_interface in uplink_interfaces %}
interface range {{ uplink_interface.interface_name }} {{ uplink_interface.switch_number }}/{{ uplink_interface.module_number }}/{{ uplink_interface.id_range }}
channel-group {{ uplink_interface.etherchannel.id }} mode {{ uplink_interface.etherchannel.mode }}
description {{ uplink_interface.description }}
exit
!
{% endfor %}
{% if snmp_server.state %}
{% if snmp_server.enable_traps %}
snmp-server enable traps
{% endif %}
{% for snmp in snmp_server.communities %}
snmp-server community {{ snmp.community_string }} {{ snmp.capabilities }}
{% endfor %}
snmp-server host {{ snmp_server.snmp_host.ip_addr }} {{ snmp_server.snmp_host.community_string }}
!
{% endif %}
{% for line in lines %}
line console 0
{% if line.console.logging_sync %}
logging synchronous
{% endif %}
{% if line.console.login_local %}
login local
{% endif %}
exec-timeout {{ line.vty.timeout_mins }}
stopbits {{ line.console.stopbits }}
exit
!
line vty {{ line.vty.range }}
{% if line.vty.logging_sync %}
logging synchronous
{% endif %}
{% if line.vty.login_local %}
login local
{% endif %}
exec-timeout {{ line.vty.timeout_mins }}
transport input {{ line.vty.transport.input }}
transport output {{ line.vty.transport.output }}
exit
{% endfor %}
!
end