2024-04-26 03:43:50 发布
网友
假设我有两个带相关参数的命令:
command1
command2
我想在ServerA上运行第一个命令,在ServerB上运行第二个命令
在fabric中通过改变env是正确的方法吗?你知道吗
env
给予还是索取,下面的方法正确吗?我不能让主机列表包含所有服务器,然后选择告诉run方法在哪个服务器上执行吗?你知道吗
run
env.hosts = ['ServerA'] run( command1 ) env.hosts = ['ServerB'] run( command2 )
谢谢!你知道吗
考虑到结构的限制,显然最好的方法是使用execute方法,而不是run。你知道吗
execute
from fabric.tasks import execute def execute_task(command, host): """ wrapper around the execute task of fabric. It runs the command remotely via ssh. """ return execute(command, host=host)
如果ssh密码是相同的,那么它将很好地工作,因为您可以在环境中设置env.password,并且不会要求您输入密码。你知道吗
env.password
考虑到结构的限制,显然最好的方法是使用
execute
方法,而不是run
。你知道吗如果ssh密码是相同的,那么它将很好地工作,因为您可以在环境中设置
env.password
,并且不会要求您输入密码。你知道吗相关问题 更多 >
编程相关推荐