After building out the ZTP server, I was curious if I could take it a step further. My goal was to cut down on the time it takes to create and upload my switch configuration files. I accomplished this by using Python and Jinja2. Presto, I now have a quick and easy way to give each device a custom configuration file and IP address reservation.
Be sure to head over to my github account to pull a copy of the code used for this example.
The CSV file is used to add personalized information.
Information from the csv file's mac_address column is used to generate information for the dhcpd.conf file.
host {{hostname}}{ hardware ethernet {{mac_address}}; fixed-address {{man_ip}}; option routers 192.168.255.1; option subnet-mask 255.255.255.0; option zerop.config-file-name "{{hostname}}.config"; }
Other fields from the csv file are used to generate a configuration for the switch:
system { host-name {{hostname}}; auto-snapshot; root-authentication encrypted-password {{rootPass}}; services { ssh { protocol-version v2; } netconf { ssh; } } commit synchronize; }
Stay tuned for one final post in the series. In the last post, I will walk through what you should expect to see on a switch during the ZTP process.