寻找一个使用ssh在多个远程主机上命令别名的软件包

我想find一个程序,维护一个可以为不同的主机别名命令列表。 例如,我们有一个数据库服务器和四个Web服务器。 一个常见的任务是login到pipe理服务器并使用重新启动mysql

# ssh dbserver "service mysql restart" 

那么我们通过运行重新启动每个Web服务器

 # ssh webserver1 "service apache2 restart" # ssh webserver2 "service apache2 restart" # ssh webserver3 "service apache2 restart" # ssh webserver4 "service apache2 restart" 

我想有一个包跟踪这些命令,我​​可以像这样运行它们:

 # blah dbserver,webserver1-4 "restartServices" 

那么它将遍历每个列出的主机,并运行必要的命令重新启动这些框上的服务。

你可以编写你自己的bash脚本。

 #!/bin/bash ssh server 1 "service apache2 restart" ssh server 2 "service apache2 restart" ssh server 3 "service apache2 restart" etc.... 

然后运行脚本。

这可以通过几种方式来完成。

也许最简单的方法是使用pssh (并行ssh)。

如果您的需求更为复杂,则可以使用Fabric或MCollective之类的框架。

这听起来像你想要的是rundeck 。 它带有一个漂亮的网页界面,但也可以在命令行上使用。