Configuring the Initial Repository
You need to upload some files into the repository for it to actually work. To do that, go to
/tmp and check out the configurations.
conrad@gonzo:~> cd /tmp
conrad@gonzo:/tmp> svn co http://localhost/depot/routers
Checked out revision 6.
Now, run the
snmp-conf.pl script on each of your routers:
/usr/local/bin/snmp-conf --t <router ip> -o
/tmp/routers
This will populate the repository with basic files. You'll also need to run the following command on each of your routers:
conrad@gonzo:/tmp/routers> svn add 10.0.0.1.txt
A 10.0.0.1.txt
After adding them all, you'll need to run an update and then a commit:
conrad@gonzo:/tmp/routers> svn update
At revision 6.
conrad@gonzo:/tmp/routers> svn commit
Adding 10.0.0.1.txt
Transmitting file data .
Committed revision 7.
You need to check out the configurations again for things to work properly:
conrad@gonzo:/tmp> svn co http://localhost/depot/routers
Checked out revision 7.
Testing Everything Out
If you configured your repository to be updated via cron-based updates, run the
/usr/local/bin/router-cron.sh script now. It should automatically update your repository. Then, skip the next paragraph to view your results.
If you configured your repository to be updated from SNMP trap triggers, there are a few more steps. You need to restart
snmptrapd to use
snmptt. Kill
snmptrapd if it's running, and re-start it using the command
snmptrapdOn. Go to one of the routers you've configured, and make a basic configuration change. For example, you can simply change the hostname.
SomeRouter(config)# hostname AnotherRouter
AnotherRouter(config)# exit
AnotherRouter# wr
Now, you should be able to go to
http:///viewcvs, and view the configuration that was just changed, and see what changed about it. If your updates were configured via cron jobs, you are finished! Otherwise, there are just a few more steps that need to happen.
Finishing Up
Subversion needs to have the configurations checked out for updates to happen properly, so you need to set them up so they're always in the checked-out state.
Create the following script as
/usr/local/bin/router-maint.sh, and run
chmod 755 /usr/local/bin/router-maint.sh to make it executable.
#!/bin/sh
# set these for your environment
SVN=/usr/local/bin/svn
NOW=`date`
cd /tmp/routers; $SVN update
# commit any current changes
# this will throw an error the first time it is run
# You can safely ignore the error.
cd /tmp/routers; $SVN commit --message
"Auto update on $NOW"
# check out the configs
cd /tmp; $SVN co
http://gonzo.timconrad.org/depot/routers
Create a nightly cron job to do any missed updates and check out a new revision of the repository:
0 0 * * * /usr/local/bin/router-maint.sh
When I initially set up a configuration repository, I did it primarily for disaster recovery purposes. Over time, I've found that it's also very useful when I quickly need to look at a configuration for a given network device, or I'm curious as to what's changed on the router over a certain amount of time. One extension to this that would be helpful in environments with multiple network administrators, would be the capability to keep track of which user makes which change to the devices, however, that would take some additional development. Hopefully, you'll find the configuration repository as useful as I have!