Thursday 25 August 2016

RANCID with WebSVN and Centos ( for Configuration Backups)

Install Rancid
# yum install rancid
1.Edit /etc/rancid/rancid.conf
# vi /etc/rancid/rancid.conf
2.Find this line in rancid.conf:
#LIST_OF_GROUPS=”sl joebobisp”
And,underneath it add the following line: Here we adding group Switches in to which we are adding all over networks switches
We want to use Subversion for our Version Control System, and not CVS, so find the line with the parameter RCSSYS:
RCSSYS=cvs; export RCSSYS And,change it to: RCSSYS=svn; export RCSSYS and the line with CVSROOT:
And,change it to: CVSROOT=$BASEDIR/svn; export CVSROOT
Note:the lowercase “svn”. Now exit and save the file.
3. Change to the rancid user:
# su -s /bin/bash rancid
Chec kthat you ARE the rancid user:
$ id
4.Create /var/rancid/.cloginrc. Replace ip with device IP address, you can use "*" if you want to use same method for large number of devices.
for example, 10.1.*.*
$ vi /var/rancid/.cloginrc add user <ip> ssh_username add password <ip> ssh_user_pass enable_pass add method <ip> [ssh|telnet]
$ chown rancid:rancid /var/rancid/.cloginrc
$ chmod 600 /var/rancid/.cloginrc
5.Test login to the router of your group:
$ /usr/libexec/rancid/clogin
[After successful execution, you will be login to router enable mode]
6.Initialize the SVN repository for rancid:
$ /usr/libexec/rancid/rancid-cvs
7. Create the router.db file: Here "SWITCHES" is the group we created .
$ vi /var/rancid/SWITCHES/router.db
Add below link, replacing ip with actual device IP addresses
8.Run rancid!
$ /usr/libexec/rancid/rancid-run
9.Look at the configs. The backed up configs will be saved in /var/rancid/<GROUP_NAME>/configs.
$ cd /var/rancid/bdnog/configs $ less SWITCHES
10.Check the rancid log files:
$ cd /var/log/rancid $ ls -ll
Email Alert Configuration
1.Edit /etc/rancid/rancid.conf
Add this to the /etc/aliases file: (group names have to be named rancid-admin-<group listed in rancid.conf file) and rancid-<group listed in rancid.conf file>). Replace "" with correct email addrsss of you choice.
# Groups for rancid rancid-admin-all: rancid-all:
Save the file and run
CRON Schedule
1.For automated backup, you can setup CRON schedule. Please note that cron need to configured under user RANCID.
# su -s /bin/bash rancid # crontab -e # m h dom mon dow command 0 0 * * * /usr/libexec/rancid/rancid-run g
Install WEBSVN
# yum install websvn
1.Fix permissions. The web server must be able to read the SVN (Subversion) folder
# chgrp -R apache /var/rancid/svn # chmod g+w -R /var/rancid/svn
2.Change ownership of web files:
# chown apache:apache /usr/share/websvn
3.Add the following virtual host entry to your apache configuration file /etc/httpd/conf.d/websvn.conf:
Alias /websvn /usr/share/websvn <Directory /usr/share/websvn/>  DirectoryIndex index.php  Options FollowSymLinks  Options FollowSymLinks MultiViews  Order allow,deny  Allow from all  <IfModule mod_php4.c>  php_flag magic_quotes_gpc Off  php_flag track_vars On  </IfModule> </Directory>
5.Reload apache and try to browse the websvn: http://<ip_address>/websvn.
Check you can access the WebSVN.
6.Now we add RANCID repository sites. Edit websvn configuration file.
# vi /usr/share/websvn/include/config.php
// Local repositories (without and with optional group): // $config->addRepository(‘BDNOG’, ‘file:///var/rancid/svn/’);