我打算寫一個簡單的fabfile這樣安裝check_mk插件:如何使Fabric在獲取退出狀態後繼續運行下一個命令:1?
from fabric.api import env, run, roles, execute, parallel
env.roledefs = {
'monitoring': ['192.168.3.118'],
'mk-agent': ['192.168.3.230', '192.168.3.231', '192.168.3.232']
}
@roles('monitoring')
def mk():
run('[ -f check_mk-1.1.12p7.tar.gz ] || wget http://mathias-kettner.de/download/check_mk-1.1.12p7.tar.gz')
run('[ -d check_mk-1.1.12p7 ] || tar zxvf check_mk-1.1.12p7.tar.gz')
run('cd check_mk-1.1.12p7 && sudo ./setup.sh')
@parallel
@roles('mk-agent')
def mk_agent():
run('[ `rpm -qa | grep -c xinetd` -eq 0 ] && sudo yum -y install xinetd.x86_64')
run('sudo rpm -ivh http://mathias-kettner.de/download/check_mk-agent-1.2.0b2-1.noarch.rpm')
def check_mk():
execute(mk)
execute(mk_agent)
但是,正如你可以猜測,如果已經安裝了xinetd
包布將與下面的錯誤停止:
Fatal error: run() received nonzero return code 1 while executing!
Requested: [ `rpm -qa | grep -c xinetd` -eq 0 ] && sudo yum -y install xinetd.x86_64
Executed: /bin/bash -l -c "[ \`rpm -qa | grep -c xinetd\` -eq 0 ] && sudo yum -y install xinetd.x86_64"
Aborting.
這種情況有什麼解決辦法嗎?
回答鏈接是不好的做法 – 2017-02-17 04:25:18