[rancid] Adding JunOS Commands in configure mode

Dede . peacefull64 at hotmail.fr
Sat Jan 23 22:20:13 UTC 2021


Hi,

I need to run "show | compare" in JunOS by entering in configure mode, so I would like to add this command to the list of commands that gets executed against Juniper devices.

At first I tried to edit directly the files "junos.pm", "jrancid" and "rancid.types.base" but without success.
After several searches on the internet and here I found some interesting information.

https://shrubbery.net/pipermail/rancid-discuss/2015-October/008716.html
https://shrubbery.net/pipermail/rancid-discuss/2016-September/009251.html
https://shrubbery.net/pipermail/rancid-discuss/2009-October/004326.html

So I don't override commands from the base types file and copy them from rancid.types.base to rancid.types.conf and rename them.
Of course without forgetting to update the "router.db" file with the value jlocal and copy /usr/local/libexec/rancid/jrancid to /usr/local/libexec/rancid/jlocal (I use FreeBSD OS).

Example conf:
jlocal;script;rancid -t jlocal
jlocal;login;jlogin
jlocal;module;junos
jlocal;inloop;junos::inloop
jlocal;command;junos::ShowChassisClocks;show chassis clocks
jlocal;command;junos::ShowChassisEnvironment;show chassis environment
jlocal;command;junos::ShowChassisFirmware;show chassis firmware
jlocal;command;junos::ShowChassisFpcDetail;show chassis fpc detail
jlocal;command;junos::ShowChassisHardware;show chassis hardware detail
jlocal;command;junos::ShowChassisHardware;show chassis hardware models
jlocal;command;junos::ShowChassisRoutingEngine;show chassis routing-engine
jlocal;command;junos::ShowChassisSCB;show chassis scb
jlocal;command;junos::ShowChassisSCB;show chassis sfm detail
jlocal;command;junos::ShowChassisSCB;show chassis ssb
jlocal;command;junos::ShowChassisSCB;show chassis feb detail
jlocal;command;junos::ShowChassisSCB;show chassis feb
jlocal;command;junos::ShowChassisSCB;show chassis cfeb
jlocal;command;junos::ShowChassisAlarms;show chassis alarms
jlocal;command;junos::ShowSystemLicense;show system license
jlocal;command;junos::ShowSystemBootMessages;show system boot-messages
jlocal;command;junos::ShowSystemCoreDumps;show system core-dumps
jlocal;command;junos::ShowVersion;show version detail
jlocal;command;junos::ShowConfiguration;show configuration

So far everything works fine, but if I add the additional lines for my commands in "rancid.types.conf" it doesn't work anymore.

jlocal;command;junos::RunConfigure;configure
jlocal;command;junos::ShowCompare;show | compare
jlocal;command;junos::RunExit;exit

I also tried to add the commands in the @commandtable array and also to modify the variable $prompt in order to take the '#' of the configure mode.

$prompt = ($_ =~ /^([^>]+>)/)[0]; ===> $prompt = ($_ =~ /^([^>|^#]+[>|#])/)[0];

Can someone please explain to me how I can set this up? Thank you.

Regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20210123/064c5280/attachment.htm>


More information about the Rancid-discuss mailing list