我有两个用户名和相应的密码用于管理我的服务器,有没有办法让我的 fab 脚本/模块使用一个,如果第一个失败则使用第二个,而不必维护完整的凭据列表每个主机甚至一组主机。
我在文档中看不到围绕 run() 或类似的尝试/除外的方法...
run
和其他命令引发 SystemExit
from fabric.api import run,cd,put,sudo,settings
def do_stuff():
run('ls derp')
try:
with(settings(host_string='%s@localhost' % first_user,password = first_password)):
do_stuff()
except SystemExit:
with(settings(host_string='%s@localhost' % second_user,password = second_password)):
do_stuff()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)