Nikulski.net
CLI config generator for any CLI configurable devices
1. Introduction

This perl script reads-in a Template- and parameterdata-File and generates multiple Config-Files by replacing the placeholders <parameterx> with the corresponding value on the parameter file. The config files will be named after the first parameter in the data-file, so typically you should put the hostname as the first columns, then files will be named hostnamex.cli

Program arguments:
-h: just displays this help file
-t: template file with placeholder like <parameterx>
-p: parameter file with a comma or semicolon as separator, not a tab!

The first line must contain the names of the parameters
e.g. parameterx (this name is then used as placeholder)
Example:
perl genconfig.pl -p data.csv -t template.cli

The format of the data file (as an example) is as follows (separated by semicolons! Can be exported from excel!):

Hostname;Location;PrivateIP;PublicIP;PublicGW;MgmtIP;MgmtNatIP;ARLicense
Host1;anywhere;10.10.10.1;20.20.10.20;20.20.10.1;10.10.10.2;11.11.11.11;AR-1234567-1000000000-A1
Host2;there;10.10.20.1;20.20.20.20;20.20.20.1;10.10.20.2;11.11.11.12;AR-1234567-1000000000-A1

The first row carries the parameternames, these names are then used as placeholders (surrounded by brackets: <param1>) in the template file:

! System Identity Configuration
ip address <MgmtIP>
hostname <Hostname>
!
! System Lan Interface Configurations
! Interface on 0/1
interface FastEthernet 0/1
ip address <PrivateIP> 255.255.255.0
exit
! Interface on 1/1
interface FastEthernet 1/1
ip address <PublicIP> 255.255.255.224
exit
!
logging "10.10.10.11" facility LOCAL0 level NORMAL port 514
!
! Routing Static Route Configuration
router static
! ip default-network <PublicGW> public 10 enable
ip route 20.0.0.0 255.0.0.0 <PublicGW> 1 enable
!
! Routing OSPF Configuration
router ospf
router-id <MgmtIP>
exit

There are no limits on the number of parameters or length of files.