adding new devices and other features to rancid

Ed Ravin eravin at panix.com
Fri Jun 3 05:34:03 UTC 2005


On Mon, May 16, 2005 at 07:02:29PM -0400, Ed Ravin wrote:
> I just stumbled over a Perl/Expect.pm script that fetches the config
> file from an HP2424m/4000m/8000m - with a little bit of work it could
> be brought into rancid.

I've made lots of progress with this.  I'll be ready soon to post my
changes to the list, but some of them are big enough that I thought
they merit discussion first:

* support for login scripts written in Perl instead of TCL/Expect: I don't
see any major dependencies on TCL/Expect in Rancid - except for parsing
cloginrc and the "-s scriptfile" option to run your own code.  Writing
parsing code in Perl isn't a problem, but external scripts are a bit
of a dilemma.  External scripts don't seem to be needed by the core
functionality of Rancid (fetching and archiving the config), so I don't
think it breaks anything if the login script for a new device doesn't
support it.  I suppose it's possible for a Perl login script to call
a TCL/Expect program that then calls the .exp script.  Or have the Perl
login script source external Perl scripts: since the Perl/Expect.pm
combination uses similar syntax for the all-important "expect"
command, all of the same functionality is available.

The important thing is that the existing TCL/Expect login scripts will
exist side by side with the Perl login scripts, as described below.

* add an external configuration file to rancid-fe: it is cumbersome to
patch the if/else statement in rancid-fe when it could all be moved
into a table somewhere like "/etc/rancidexec.conf".  This would allow
end users to easily add device types or to use a different xxlogin or
xxrancid script for an existing device.  I haven't though much about
what the table would look like - I'm starting with the table below,
but suggestions are welcome:

   #Type      Rancid program   Login program
   cisco       rancid           clogin
   hp          hrancid          hlogin
   hp4000m     hp4000m.rancid   hp4000m.login
   [...]

* Have rancid-fe set the RANCID_CLOGIN environment var.  For xxrancid
scripts that support it, they will use that value (if it is present)
as the name of the xxlogin script to call.  Right now, all these are
hard-coded, but it's a very simple patch.

* Add PERLLIB to rancid.conf to specify where Perl modules can be found.
My Perl code that parses cloginrc is written as a module so it can be
used by multiple xxlogin programs (if they're written in Perl).

* Find some place to put my Rancid/Login.pm module.  Since only rancid
programs will use it, I don't see the point of dropping it in the usual
Perl library install directories:  how about in $prefix/share/rancid ?

* New login scripts: my already-mentioned hp4000m.login, and a Cisco rsh
(as opposed to rlogin) script I'm going to be working on next, which will
hopefully work with the existing Cisco rancid script (with the
above-mentioned patch for telling it which login script to call).  Also,
we use S/Key one-time passwords at my shop, so I'm going to have to code
up something that can generate the OTPs when needed.

Does everything here sound reasonable?  I feel a little funny proposing
all these changes, especially since I've hardly used Rancid yet (my
environment more or less demands the above features - until I finish
them I can't take advantage of Rancid).

I think using Perl modules is a big win for future code-sharing
between scripts, since once I've finished the parsing and OTP stuff any
other script can use it.  Even Expect/TCL scripts - since most Unix systems
support /dev/stdin or /dev/fd/NN, it should be possible for an Expect/TCL
script to ask a Perl script to do some of the transactions on the session.

	-- Ed



More information about the Rancid-discuss mailing list