带有错误警告的远程服务器的结构脚本调用

时间:2019-06-21 09:14:12

标签: python fabric

我正在使用下面的Fabric脚本在远程主机上运行,​​该主机基本上调用python脚本/hm/it_script/DC/scripts/mainRun.py并在文件上收集输出。我正在使用sudo用户连接到远程主机。

下面的代码有效,但返回一些警告和错误。

import sys
from fabric.api import env
from fabric.operations import sudo
from fabric.api import settings

env.skip_bad_hosts=True
env.command_timeout=120
env.user = 'trooper'
env.shell = "/bin/sh -c"
env.warn_only = True
env.password = 'pass4321'
def read_hosts():
    env.hosts = [line.strip() for line in sys.stdin.readlines()]

def system_Health():
      with settings(warn_only=True):
                   output=sudo("/hm/it_script/DC/scripts/mainRun.py", shell=False)

错误日志:

    Warning: One or more hosts failed while executing task 'system_Health'
    Warning: sudo() received nonzero return code 1 while executing '/hm/it_script/DC/scripts/mainRun.py'!

    Warning: sudo() received nonzero return code 127 while executing '/hm/it_script/DC/scripts/mainRun.py'!

   Warning: sudo() received nonzero return code 127 while executing '/hm/it_script/DC/scripts/mainRun.py'!

    Fatal error: Needed to prompt for a connection or sudo password (host: server02), but input would be ambiguous in parallel mode Aborting.

    Fatal error: Needed to prompt for a connection or sudo password (host: server01), but input would be ambiguous in parallel mode Aborting.

所需建议:

如何避免这些错误或警告,请多多指教和帮助。

织物版本:1.14

0 个答案:

没有答案
相关问题