I have 100 servers which need a new backup server added to a text file, and then the backup agent restarted.

Ove Pettersen ove.pettersen at smartcall.no
Sun Jul 2 16:05:21 EDT 2006


gavino wrote:
> This seems easy but I have been asking tcl and python IRC chat all day
> and no one gave an answer.
> I have 100 servers which need a new backup server added to a text file,
>  and then the backup agent restarted.
> If I have a list of the servers, all with same root password, and the
> connection is ssh.
> How do I connect to the server, cat the line to the config file, stop
> adn start the agent, and then do same to next server in list and
> iterate through the 100 servers. 
> What script would allow this?
> 

I wouldn't use python at all (like swearing on this list???) .... simple 
shell-command is more than sufficient.

for server in "server1 server2 server3 .... server100"
do
    ssh root@$server "(echo "new line" >> config.file; stop-command ; 
sleep 5 ; start-command)"
done

I would however have extended the procedure with a few more checks...
Like:
* only add new line to config-file if it isn't present
* only do restart if config-file was modified

Regards,



More information about the Python-list mailing list