2012-10-13 31 views
2

下面的结构脚本是我需要使用的开源代码,不幸的是我对这个东西并不熟悉。结构文件开头为:旁路错误

from fabric.api import * 
import time 

env.user = 'aegir' 
env.shell = '/bin/bash -c' 

# Download and import a platform using Drush Make 
def build_platform(site, profile, webserver, dbserver, makefile, build): 
  print "===> Building the platform..." 
  run("drush make %s /var/aegir/platforms/%s" % (makefile, build)) 

当Git push触发新构建时,构造文件由Jenkins服务器运行。当执行这个文件时,第一个远程动作(最后一行)会导致以下错误。

/usr/lib/python2.6/getpass.py:83: GetPassWarning: Can not control echo on the terminal. 
    passwd = fallback_getpass(prompt, stream) 
Warning: Password input may be echoed. 
Password for [email protected]: ===> Building the platform... 
[o1.sub.aegir.local] run: drush make https://raw.github.com/mig5/builds/master/mig5_platform.build /var/aegir/platforms/20121011010955 
Traceback (most recent call last): 
    File "/usr/lib/pymodules/python2.6/fabric/main.py", line 435, in main 
    commands[name](*args, **kwargs) 
    File "/usr/local/bin/fabfile.py", line 11, in build_platform 
    run("drush make %s /var/aegir/platforms/%s" % (makefile, build)) 
    File "/usr/lib/pymodules/python2.6/fabric/network.py", line 390, in host_prompting_wrapper 
    return func(*args, **kwargs) 
    File "/usr/lib/pymodules/python2.6/fabric/operations.py", line 414, in run 
    channel = connections[env.host_string]._transport.open_session() 
    File "/usr/lib/pymodules/python2.6/fabric/network.py", line 65, in __getitem__ 
    self[real_key] = connect(user, host, port) 
    File "/usr/lib/pymodules/python2.6/fabric/network.py", line 219, in connect 
    password = prompt_for_password(password, text) 
    File "/usr/lib/pymodules/python2.6/fabric/network.py", line 279, in prompt_for_password 
    new_password = getpass.getpass(password_prompt) 
    File "/usr/lib/python2.6/getpass.py", line 83, in unix_getpass 
    passwd = fallback_getpass(prompt, stream) 
    File "/usr/lib/python2.6/getpass.py", line 118, in fallback_getpass 
    return _raw_input(prompt, stream) 
    File "/usr/lib/python2.6/getpass.py", line 135, in _raw_input 
    raise EOFError 
EOFError 
Build step 'Execute shell' marked build as failure 
Finished: FAILURE 

我需要为aegir用户指定一个密码吗?我试图在env.user = 'aegir'下包含env.password = ''(我在远程计算机上删除了Aegir的用户密码passwd --delete aegir),但这并没有解决任何问题。

回答

2

ssh服务禁止没有密码的用户进行远程访问。您可以在机器上和fabfile中为aegir用户设置密码。

+0

好的,那确实是问题所在。愚蠢的我没有尝试。谢谢! – jroeleveld

1

需要登录。为避免交互性,您可以从FABRIC机器复制公钥并粘贴到TARGET机器的〜/ .ssh/authorized_keys

请确保: 不要包含或排除任何不是关键的东西(如引入换行符) ,密钥必须完全按原样复制。

,并做到这一点:

chmod 600 ~/.ssh/authorized_keys 
chmod 700 ~/.ssh/* 
+1

如果以上所有都失败了,该怎么办? – Max

0

使用此功能和炸弹!

output['running'] = False  # Avoid fabric to output what it is doing behind the scenes 
 
output['stdout'] = False  # Do not show stdout 
 
output['stderr'] = False  # Do not show stderr 
 
output['status'] = False  # Prevent fabric from using print in some situations (at least in disconnect_all) 
 
output['warnings'] = False  # Avoid fabric from showing messages about failed commands 
 

 
def run_it(command, user, host, port, keyfile): 
 
    env.host_string = "%[email protected]%s:%s" % (user, host, port) 
 
    env.key_filename = keyfile 
 
    try: 
 
     res = run(command, pty=False, shell=True) 
 
     print "SUCCESS: return_code=%s" % (return_code) 
 
    except Exception, e: 
 
     print "ERROR : %s" % (e) 
 
     stdout, return_code = None, None 
 
    return stdout, return_code

附:不要将密钥列表传递给env.key_filename