-
Notifications
You must be signed in to change notification settings - Fork 1
/
nexus-configurator.sh
executable file
·855 lines (712 loc) · 23 KB
/
nexus-configurator.sh
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
#!/bin/sh
#
# nexus-configurator.sh
#
# Created by Colin McNamara on 2/13/11.
# Copyright 2011 Colin McNamara. All rights reserved.
# http://www.colinmcnamara.com colin@2cups.com http://www.twitter.com/colinmcnamara
OIFS=$IFS
IFS=,
version=v2.6
# test for the required local directories
# if they don't exist create them
if [ -d config-output ]
then
echo "******************************************"
echo " config-output directory found "
rm -rf config-output/*.txt
echo " cleaning out config-output directory "
else
mkdir config-output
fi
if [ -d tmp ]
then
echo "******************************************"
echo " temp directory found "
rm -rf tmp/*.txt
echo " cleaning out temp directory "
else
mkdir .tmp
fi
if [ -d config-elements ]
then
echo "******************************************"
echo " config-elements directory found "
rm -rf config-elements/*.txt
echo " cleaning out config-elements directory "
else
mkdir config-elements
fi
if [ -f interface-assignments.csv ]
then
echo "******************************************"
echo " interface-assigments.csv file found "
else
echo "******************************************"
echo " please create interface-assigments.csv and place in the same directory as this script"
fi
# put the version number into VERSION.TXT
echo "Version $version" > VERSION.TXT
# match the following field descriptions to your CSV file column names
while read srcsys site cell zone tile type nodenum vdcid srcpo srcchannelgroup srcipaddress subnetmask srcmemberint dstsys dstmemberint defaultgw ospfarea nativevlan allowdvlans vlanid vpcid mtu l2po l2pomember l3po l3pomember vpcpo vpcpomember peerlinkpo peerlinkpomember peerkeepalivelink peerkeepalivelinkmember mgmt loopback vpca vpcb hsrpa hsrpb tacacs n7k n5k fexpo fexpomember
do
echo "******************************************"
echo "srcsys -> [${srcsys}]"
echo "site -> [${site}]"
echo "cell -> [${cell}]"
echo "zone -> [${zone}]"
echo "tile -> [${tile}]"
echo "type -> [${type}]"
echo "nodenum -> [${vdcid}]"
echo "vdcid -> [${vdcid}]"
echo "srcpo -> [${srcpo}]"
echo "srcchannelgroup -> [${srcchannelgroup}]"
echo "srcipaddress -> [${srcipaddress}]"
echo "subnetmask -> [${subnetmask}]"
echo "srcmemberint -> [${srcmemberint}]"
echo "dstsys -> [${dstsys}]"
echo "dstmemberint -> [${dstmemberint}]"
echo "defaultgw -> [${defaultgw}]"
echo "nativevlan -> [${nativevlan}]"
echo "ospfarea -> [${ospfarea}]"
echo "allowedvlan -> [${allowedvlan}]"
echo "vlanid -> [${vlanid}]"
echo "vpcid -> [${vpcid}]"
echo "mtu -> [${mtu}]"
echo "l2po -> [${l2po}]"
echo "l2pomember -> [${l2pomember}]"
echo "l3po -> [${l3po}]"
echo "l3pomember -> [${l3pomember}]"
echo "vpcpo -> [${vpcpo}]"
echo "vpcpomember -> [${vpcpomember}]"
echo "peerlinkpo -> [${peerlinkpo}]"
echo "peerlinkpomember -> [${peerlinkpomember}]"
echo "peerkeepalivelink -> [${peerkeepalivelink}]"
echo "peerkeepalivelinkmember -> [${peerkeepalivelinkmember}]"
echo "mgmt -> [${mgmt}]"
echo "loopback -> [${loopback}]"
echo "vpca -> [${vpca}]"
echo "vpcb -> [${vpcb}]"
echo "hsrpa -> [${hsrpa}]"
echo "hsrpb -> [${hsrpb}]"
echo "tacacs -> [${tacacs}]"
echo "n7k -> [${n7k}]"
echo "n5k -> [${n5k}]"
echo "fexpo -> [${fexpo}]"
echo "fexpomember -> [${fexpomember}]"
if [ "$mgmt" == "TRUE" ] && [ "$vdcid" == "1" ]
then
#create the base config
#move all interfaces into vdc 2
echo "
hostname $srcsys-rootvdc
vdc $srcsys-rootvdc id 1
limit-resource vlan minimum 16 maximum 4094
limit-resource monitor-session minimum 0 maximum 2
limit-resource monitor-session-erspan-dst minimum 0 maximum 23
limit-resource vrf minimum 2 maximum 1000
limit-resource port-channel minimum 0 maximum 768
limit-resource u4route-mem minimum 96 maximum 96
limit-resource u6route-mem minimum 24 maximum 24
limit-resource m4route-mem minimum 58 maximum 58
limit-resource m6route-mem minimum 8 maximum 8
vdc $srcsys id 2
limit-resource vlan minimum 16 maximum 4094
limit-resource monitor-session minimum 0 maximum 2
limit-resource monitor-session-erspan-dst minimum 0 maximum 23
limit-resource vrf minimum 2 maximum 1000
limit-resource port-channel minimum 0 maximum 768
limit-resource u4route-mem minimum 96 maximum 96
limit-resource u6route-mem minimum 24 maximum 24
limit-resource m4route-mem minimum 58 maximum 58
limit-resource m6route-mem minimum 8 maximum 8
allocate interface ethernet 1/1-8
allocate interface ethernet 2/1-8
allocate interface ethernet 3/1-8
allocate interface ethernet 4/1-32
allocate interface ethernet 5/1-32
allocate interface ethernet 6/1-32
allocate interface ethernet 7/1-32
allocate interface ethernet 8/1-32
allocate interface ethernet 11/1-48
allocate interface ethernet 12/1-48
allocate interface ethernet 13/1-48
vdc $srcsys-otv id 3
limit-resource vlan minimum 16 maximum 4094
limit-resource monitor-session minimum 0 maximum 2
limit-resource monitor-session-erspan-dst minimum 0 maximum 23
limit-resource vrf minimum 2 maximum 1000
limit-resource port-channel minimum 0 maximum 768
limit-resource u4route-mem minimum 96 maximum 96
limit-resource u6route-mem minimum 24 maximum 24
limit-resource m4route-mem minimum 58 maximum 58
limit-resource m6route-mem minimum 8 maximum 8
no vdc combined-hostname
cfs eth distribute
feature ospf
feature private-vlan
feature udld
feature interface-vlan
feature hsrp
feature lacp
feature lldp
username colin role network-admin password 1Cisco123
ip domain-lookup
system jumbomtu 9000
ntp server 192.43.244.18 use-vrf management
ntp server 192.43.244.18 use-vrf management
clock timezone GMT 0 0
clock summer-time MDT
cli alias name wri copy run start
cli alias name wr copy run start
cli alias name swt switchto vdc
line console
line vty
logging logfile LOG-FILE 7 size 64000
logging server 1.1.1.1 5 use-vrf management
logging timestamp microseconds
logging level local7 6
snmp-server community readonly ro
snmp-server community readwrite rw
snmp-server host 1.1.1.1 password
snmp-server host 1.1.1.1 traps password
snmp-server host 1.1.1.1 source-interface mgmt 0
snmp-server host 1.1.1.1 use-vrf management
snmp-server enable traps feature-control FeatureOpStatusChange
snmp-server enable traps rmon risingAlarm
snmp-server enable traps rmon fallingAlarm
snmp-server enable traps rmon hcRisingAlarm
snmp-server enable traps rmon hcFallingAlarm
snmp-server enable traps config ccmCLIRunningConfigChanged
snmp-server enable traps snmp authentication
" >> ./config-elements/$srcsys.vdc1.a1.base-config.tmp.txt
fi
if [ "$mgmt" == "TRUE" ] && [ "$vdcid" == "2" ]
then
echo "
end
switchback
switchto vdc $srcsys
config t
hostname $srcsys
cfs eth distribute
feature ospf
feature private-vlan
feature udld
feature interface-vlan
feature hsrp
feature lacp
feature lldp
username colin role network-admin password 1Cisco123
ip domain-lookup
system jumbomtu 9000
ntp server 192.43.244.18 use-vrf management
ntp server 192.43.244.18 use-vrf management
clock timezone GMT 0 0
clock summer-time MDT
cli alias name wri copy run start
cli alias name wr copy run start
cli alias name swt switchto vdc
line console
line vty
logging logfile LOG-FILE 7 size 64000
logging server 1.1.1.1 5 use-vrf management
logging timestamp microseconds
logging level local7 6
snmp-server community readonly ro
snmp-server community readwrite rw
snmp-server host 1.1.1.1 password
snmp-server host 1.1.1.1 traps password
snmp-server host 1.1.1.1 source-interface mgmt 0
snmp-server host 1.1.1.1 use-vrf management
snmp-server enable traps feature-control FeatureOpStatusChange
snmp-server enable traps rmon risingAlarm
snmp-server enable traps rmon fallingAlarm
snmp-server enable traps rmon hcRisingAlarm
snmp-server enable traps rmon hcFallingAlarm
snmp-server enable traps config ccmCLIRunningConfigChanged
snmp-server enable traps snmp authentication
" >> ./config-elements/$srcsys.vdc2.a2.base-config.tmp.txt
fi
# pop out base config for OTV VDC
if [ "$mgmt" == "TRUE" ] && [ "$vdcid" == "3" ]
then
echo "
end
switchback
switchto vdc $srcsys-otv
config t
hostname $srcsys-otv
cfs eth distribute
feature ospf
feature private-vlan
feature udld
feature interface-vlan
feature hsrp
feature lacp
feature lldp
feature otv
username colin role network-admin password 1Cisco123
ip domain-lookup
system jumbomtu 9000
ntp server 192.43.244.18 use-vrf management
ntp server 192.43.244.18 use-vrf management
clock timezone GMT 0 0
clock summer-time MDT
cli alias name wri copy run start
cli alias name wr copy run start
cli alias name swt switchto vdc
line console
line vty
logging logfile LOG-FILE 7 size 64000
logging server 1.1.1.1 5 use-vrf management
logging timestamp microseconds
logging level local7 6
snmp-server community readonly ro
snmp-server community readwrite rw
snmp-server host 1.1.1.1 password
snmp-server host 1.1.1.1 traps password
snmp-server host 1.1.1.1 source-interface mgmt 0
snmp-server host 1.1.1.1 use-vrf management
snmp-server enable traps feature-control FeatureOpStatusChange
snmp-server enable traps rmon risingAlarm
snmp-server enable traps rmon fallingAlarm
snmp-server enable traps rmon hcRisingAlarm
snmp-server enable traps rmon hcFallingAlarm
snmp-server enable traps config ccmCLIRunningConfigChanged
snmp-server enable traps snmp authentication
!end
!switchback
" >> ./config-elements/$srcsys.vdc3.a3.base-config.tmp.txt
fi
# create base config for n5k
if [ "$mgmt" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
echo "
config t
hostname $srcsys
feature telnet
cfs eth distribute
feature interface-vlan
feature lacp
feature vpc
feature fex
username colin role network-admin password 1Cisco123
ip domain-lookup
system jumbomtu 9000
cli alias name wri copy run start
cli alias name wr copy run start
cli alias name swt switchto vdc
line console
line vty
logging logfile LOG-FILE 7 size 64000
logging server 1.1.1.1 5 use-vrf management
logging server 1.1.1.1 5 use-vrf management
logging server 1.1.1.1 5 use-vrf management
logging timestamp microseconds
logging level local7 6
snmp-server community readonly ro
snmp-server community readwrite rw
snmp-server host 1.1.1.1 password
snmp-server host 1.1.1.1 traps password
snmp-server host 1.1.1.1 source-interface mgmt 0
snmp-server host 1.1.1.1 use-vrf management
snmp-server enable traps feature-control FeatureOpStatusChange
snmp-server enable traps rmon risingAlarm
snmp-server enable traps rmon fallingAlarm
snmp-server enable traps rmon hcRisingAlarm
snmp-server enable traps rmon hcFallingAlarm
snmp-server enable traps config ccmCLIRunningConfigChanged
snmp-server enable traps snmp authentication
policy-map type network-qos jumbo
class type network-qos class-default
mtu 9000
system qos
service-policy type network-qos jumbo
" >> ./config-elements/$srcsys.vdc$vdcid.a1.base-config.tmp.txt
fi
if [ "$l3pomember" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
mtu $mtu
logging event port link-status
udld aggressive
! rate-mode dedicated force
channel-group $srcchannelgroup mode active
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.c1.l3pomember.tmp.txt
fi
if [ "$l3po" == "TRUE" ]
then
echo "
interface po$srcchannelgroup
description l3-link to $dstsys
logging event port link-status
mtu $mtu
ip address $srcipaddress$subnetmask
ip ospf dead-interval 3
ip ospf hello-interval 1
ip ospf network point-to-point
ip router ospf 1 area $ospfarea
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b1.l3po.tmp.txt
fi
# N7K PEER LINK CONFIGS
if [ "$peerlinkpomember" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
switchport
switchport mode trunk
switchport trunk native vlan $nativevlan
! rate-mode dedicated force
mtu $mtu
channel-group $srcchannelgroup mode active
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.c2.l2peerlinkmember.tmp.txt
fi
if [ "$peerlinkpo" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
switchport
switchport mode trunk
switchport trunk native vlan $nativevlan
switchport trunk allowed vlan 1-4093
switchport trunk allowed vlan remove 2
spanning-tree port type network
mtu $mtu
vpc peer-link
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b2.lpeerlinkpo.tmp.txt
fi
## N5K PEER LINK CONFIGS
if [ "$peerlinkpomember" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
switchport mode trunk
switchport trunk native vlan $nativevlan
switchport trunk allowed vlan 1-4093
switchport trunk allowed vlan remove 2
channel-group $srcchannelgroup mode active
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.c2.l2peerlinkmember.tmp.txt
fi
if [ "$peerlinkpo" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
switchport mode trunk
switchport trunk native vlan $nativevlan
switchport trunk allowed vlan 1-4093
switchport trunk allowed vlan remove 2
spanning-tree port type network
vpc peer-link
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b2.lpeerlinkpo.tmp.txt
fi
## N7K vpc po config
if [ "$vpcpomember" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
switchport
switchport mode trunk
switchport trunk native vlan $nativevlan
switchport trunk allowed vlan 1-4093
switchport trunk allowed vlan remove 2
mtu $mtu
channel-group $srcchannelgroup mode active
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.c2.vpcpomember.tmp.txt
fi
if [ "$vpcpo" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
switchport
switchport mode trunk
switchport trunk native vlan $nativevlan
switchport trunk allowed vlan 1-4093
switchport trunk allowed vlan remove 2
mtu $mtu
vpc $vpcid
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b2.vpcpo.tmp.txt
fi
## N5K vpc po config
if [ "$vpcpomember" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
switchport mode trunk
switchport trunk native vlan $nativevlan
switchport trunk allowed vlan 1-4093
switchport trunk allowed vlan remove 2
channel-group $srcchannelgroup mode active
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.c2.vpcpomember.tmp.txt
fi
if [ "$vpcpo" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
vpc $vpcid
switchport mode trunk
switchport trunk native vlan $nativevlan
switchport trunk allowed vlan 1-4093
switchport trunk allowed vlan remove 2
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b2.vpcpo.tmp.txt
fi
## Fex po member po config with fex attatched
if [ "$n5k" == "TRUE" ] && [ "$fexpomember" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
fex associate $vpcid
switchport mode fex-fabric
channel-group $srcchannelgroup
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.c2.vpcpomemberfex.tmp.txt
fi
if [ "$n5k" == "TRUE" ] && [ "$fexpo" == "TRUE" ]
then
echo "
interface $srcmemberint
description $dstsys $dstmemberint
switchport mode fex-fabric
vpc $vpcid
fex associate $vpcid
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b2.fexpo.tmp.txt
fi
if [ "$n5k" == "TRUE" ] && [ "$fexpo" == "TRUE" ]
then
echo "
fex $vpcid
description $dstsys
" >> ./config-elements/$srcsys.vdc$vdcid.a9.fex-description.tmp.txt
fi
#option for creating n7k peer keep-alives
if [ "$peerkeepalivelink" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
echo "
interface $srcmemberint
description keepalive interface $dstsys $dstmemberint
logging event port link-status
vrf member peerkeepalive
ip address $srcipaddress$subnetmask
mtu $mtu
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b3.peerkeepalivelink.tmp.txt
fi
if [ "$peerkeepalivelinkmember" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
echo "
interface $srcmemberint
description keepalive member interface $dstsys $dstmemberint
mtu $mtu
logging event port link-status
udld aggressive
channel-group $srcchannelgroup mode active
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.c3.peerkeepalivelinkmember.tmp.txt
fi
## option for creating n5k peer keep-alives
if [ "$peerkeepalivelink" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
echo "
interface $srcmemberint
description keepalive interface $dstsys $dstmemberint
ip address $srcipaddress$subnetmask
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b3.peerkeepalivelink.tmp.txt
fi
if [ "$peerkeepalivelinkmember" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
echo "
interface $srcmemberint
description keepalive member interface $dstsys $dstmemberint
switchport access vlan $vlanid
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.c3.peerkeepalivelinkmember.tmp.txt
fi
if [ "$loopback" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
#create the loopack interface first
echo "
interface $srcmemberint
ip address $srcipaddress$subnetmask
description loopback interface for $srcsys
ip router ospf 1 area $ospfarea
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b4.loopback.tmp.txt
#create the ospf statements while we are here
fi
if [ "$loopback" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
echo "
route-map static-2-ospf permit 10
router ospf 1
router-id $srcipaddress
redistribute static route-map static-2-ospf
log-adjacency-changes
auto-cost reference-bandwidth 100000 " >> ./config-elements/$srcsys.vdc$vdcid.z1.ospf.tmp.txt
fi
if [ "$mgmt" == "TRUE" ]
then
#create the mgmt interface description
echo "
interface $srcmemberint
ip address $srcipaddress$subnetmask
description management interface for $srcsys
no shutdown" >> ./config-elements/$srcsys.vdc$vdcid.b5.mgmt.tmp.txt
#give the mgmt interface a default route
echo "
vrf context management
ip route 0.0.0.0/0 $defaultgw " >> ./config-elements/$srcsys.vdc$vdcid.b6.mgmt-gw.tmp.txt
fi
# create vpc configurations for n7k
if [ "$vpca" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
#create create the VPC primary configuration
echo "
feature vpc
vrf context peerkeepalive
spanning-tree mode rapid-pvst
spanning-tree vlan 1-3967,4048-4093 priority 0
udld aggressive
vpc domain 1
role priority 3000
peer-keepalive destination 169.254.1.2 source 169.254.1.1 vrf peerkeepalive
peer-gateway " >> ./config-elements/$srcsys.vdc$vdcid.a2.vpc.tmp.txt
fi
if [ "$vpcb" == "TRUE" ] && [ "$n7k" == "TRUE" ]
then
#create create the VPC secondary configuration
echo "
feature vpc
vrf context peerkeepalive
spanning-tree mode rapid-pvst
spanning-tree vlan 1-3967,4048-4093 priority 4096
vpc domain 1
role priority 6000
peer-keepalive destination 169.254.1.1 source 169.254.1.2 vrf peerkeepalive
peer-gateway" >> ./config-elements/$srcsys.vdc$vdcid.a3.vpc.tmp.txt
fi
# create vpc configurations for n5k
if [ "$vpca" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
#create create the VPC primary configuration
echo "
feature vpc
spanning-tree mode rapid-pvst
spanning-tree vlan 1-3967,4048-4093 priority 0
vlan 2
name peerkeepalive
vpc domain 2
role priority 3000
peer-keepalive destination 169.254.1.2 source 169.254.1.1 vrf default
" >> ./config-elements/$srcsys.vdc$vdcid.c1.vpc.tmp.txt
fi
if [ "$vpcb" == "TRUE" ] && [ "$n5k" == "TRUE" ]
then
#create create the VPC secondary configuration
echo "
feature vpc
spanning-tree mode rapid-pvst
spanning-tree vlan 1-3967,4048-4093 priority 4096
vlan 2
name peerkeepalive
vpc domain 2
role priority 6000
peer-keepalive destination 169.254.1.1 source 169.254.1.2 vrf default
" >> ./config-elements/$srcsys.vdc$vdcid.c1.vpc.tmp.txt
fi
## note HSRP part of the code is unfinished ##
if [ "$hsrpa" == "TRUE" ]
then
#create create the primary hsrp configuration
echo "
vlan $vlanid
name vlan $vlanid" >> ./config-elements/$srcsys.vdc$vdcid.a4.vlana.tmp.txt
echo "
interface $srcmemberint
no shutdown
mtu $mtu
no ip redirects
ip address $srcipaddress$subnetmask
hsrp version 2
hsrp $vlanid
preempt
priority 110
ip 10.1.$vlanid.1
no shutdown
" >> ./config-elements/$srcsys.vdc$vdcid.a4.hsrpa.tmp.txt
fi
## note HSRP part of the code is unfinished ##
if [ "$hsrpb" == "TRUE" ]
then
#create create the primary hsrp configuration
echo "
vlan $vlanid
name vlan $vlanid" >> ./config-elements/$srcsys.vdc$vdcid.a4.vlanb.tmp.txt
echo "
interface $srcmemberint
no shutdown
mtu $mtu
no ip redirects
ip address $srcipaddress$subnetmask
hsrp version 2
hsrp $vlanid
ip 10.1.$vlanid.1
no shutdown
" >> ./config-elements/$srcsys.vdc$vdcid.a4.hsrpb.tmp.txt
fi
if [ "$mgmt" == "TRUE" ] && [ "$tacacs" == "TRUE" ]
then
#create create the tacacs configurtion
echo "
feature tacacs+
tacacs-server host 1.1.1.1 key secret timeout 10
tacacs-server host 1.1.1.2 key secret timeout 10
tacacs-server host 1.1.1.3 key secret timeout 10
tacacs-server host 1.1.1.4 key secret timeout 10
aaa group server tacacs+ AAA_SERVERS
server 1.1.1.1
server 1.1.1.2
server 1.1.1.3
server 1.1.1.4
use-vrf management
source-interface mgmt0
aaa authentication login default group AAA_SERVERS
aaa authentication login console group AAA_SERVERS
aaa authentication login console fallback error local
banner motd ^
Access to this system is limited to authorized users for company
business purposes only.
^C
" >> ./config-elements/$srcsys.vdc$vdcid.z2.tacacs.tmp.txt
fi
if [ "$mgmt" == "TRUE" ]
then
echo "
$srcipaddress $srcsys.vdc$vdcid " >> tmp/hosts.skynet.tmp.txt
fi
#create a temporary file with a list of hostnames in the file (I should probably do this in memory in the future, and dedup on entry)
echo "$srcsys" >> tmp/srcsys.tmp.txt
#end the while loop reading in file
done < interface-assignments.csv
echo " "
echo " deduplicating source system list"
#deduplicate the host list
awk '!($0 in a) {a[$0];print}' < tmp/srcsys.tmp.txt > tmp/srcsys.deduped1.tmp.txt
#remove blank lines
sed '/^$/d' tmp/srcsys.deduped1.tmp.txt > tmp/srcsys.deduped2.tmp.txt
#remove Source system from the host name file
sed '/Source system/d' tmp/srcsys.deduped2.tmp.txt > tmp/srcsys.deduped.tmp.txt
# combine all the config elements into master configs
echo " "
echo " concatenating config elements into master configs "
while read srcsys
do
echo "******************************************"
echo "creating configuration -> [${srcsys}]"
cat ./config-elements/$srcsys* > ./config-output/$srcsys.config.txt
done < tmp/srcsys.deduped.tmp.txt