[rancid] Re: Using Rancid to pus DST changes

Justin Shore justin at justinshore.com
Thu Mar 8 17:34:35 UTC 2007


I basically do the same thing only I pull the device names out of the 
router.db files just in case I have some configured devices that are 
configured as being down.  If I really wanted to be thorough I would 
read routers.down as input and exclude those hosts from the $LIST (or 
just read in routers.up).

LIST=$(cat var/gro/router.db  | egrep -v "down|FW|fw|4006|gro-2621" | 
awk -F ":" '{print $1}'); echo $LIST

I pick out all the devices that either can use the commands or I don't 
want the commands executed on, plus all the devices that are configured 
as down.

for i in $LIST; do clogin -x commands.run $i; done

With a little more effort I could output a list of devices that I could 
successfully apply the commands and those that I couldn't but I haven't. 
  I watch the output anyhow.

Justin



Chris Moody wrote:
> Or, even easier.
> 
> Write the line(s) of config you want to issue on every device into a 
> file....I'll call it `dst-config`.
> 
> Then, issue the following:
> ------
> ./clogin -f .cloginrc -x dst-config <device>
> 
> 
> 
> I personally create a shell for loop:
> ------
> ex>
> for i in `cat .cloginrc | grep user | cut -f 2 `; do ./clogin -f 
> .cloginrc -x dst-config $i ; done
> 
> 
> Basically, you just need to feed the first command a device name...and 
> clogin will handle issuing the correct command(s) for you.
> 
> Easy.
> 
> I did the same operation to some systems under my control for DST.  I 
> had my firewalls and network gear all updated in a matter of a few minutes.
> 
> Please feel free to contact me offline if you need more help.  This type 
> of operation is VERY easy to accomplish and really shows how much rancid 
> shines.
> 
> Cheers,
> -Chris
> 
> 
> Robin Mordasiewicz wrote:
>> On Wed, 7 Mar 2007, Todd Heide wrote:
>>
>>> How can I use (if I can) rancid to push a configuration change for the DST to all the routers? Basically it is one line,
>>> clock summer-time CST recurring 2 Sun Mar 2:00 1 Sun Nov 2:00
>> One thing you can use is expect. Here is a simple example expect script 
>> which you can run on each router which looping through your router.db file
>>
>> [ myusername at localhost ]$ expect -f summertime_DST.exp myrouter.mydomain.com
>>
>> < summertime_DST.exp >
>> #!/usr/bin/expect -f
>> #
>> set force_conservative 0  ;# set to 1 to force conservative mode even if
>>                            ;# script wasn't run conservatively originally
>> if {$force_conservative} {
>>          set send_slow {1 .1}
>>          proc send {ignore arg} {
>>                  sleep .1
>>                  exp_send -s -- $arg
>>          }
>> }
>>
>> set timeout -1
>> set userid "myusername"
>> set vtypasswd "mypassword"
>> set rtr [lindex $argv 0]
>>
>> spawn telnet $rtr
>> match_max 100000
>>
>> expect {
>>           {Username}   { send "$userid\r"
>>                          expect {
>>                                    {*Password*} { send "$vtypasswd\r" }
>>                                 }
>>                        }
>>           {telnet>}    { send_user "$rtr - telnet failed\n"
>>                         exit
>>                        }
>>           {Password}   { send "$vtypasswd\r" }
>>         }
>>
>>
>>
>> send -- "conf t\r"
>> send -- "clock summer-time $DST_timezone recurring 2 Sun Mar 2:00 1 Sun Nov 2:00\r"
>> send -- "wr mem\r"
>> send -- "end\r"
>> send -- "exit\r"
>>
>> expect eof
>>
>> < /summertime_DST.exp >
>>
>> _______________________________________________
>> Rancid-discuss mailing list
>> Rancid-discuss at shrubbery.net
>> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
>>
>>
> _______________________________________________
> Rancid-discuss mailing list
> Rancid-discuss at shrubbery.net
> http://www.shrubbery.net/mailman/listinfo.cgi/rancid-discuss
> 
> 




More information about the Rancid-discuss mailing list