Henry ON
2014-05-13 02:39:59 UTC
Hi Fabfile admin.
Recently, I use fab to deploy some middleware or run some command on remote server. but even if I specified the env.password(s)¡£ when I run the fab, still prompt me to provide the password.
any ideas or suggestion?
The code like below import sys,os,timefrom fabric.api import *from fabric.api import local,outputoutput['output']=Trueimport fabricimport logging
logging.basicConfig(level=logging.DEBUG)def host(str=''): if str == '-': list = _to_list(sys.stdin) else: list = str.split('\n') env.hosts = _to_hosts(list) print env.hosts #print "Here OOOOOOO" env.passwords = _to_passwords(list) #netifs = _to_netifs(list) print env.passwords
#env.password={'10.150.110.171':'TVLE800G'}
def _to_list(handle): list = [] while True: line = handle.readline().strip() print line if line: list.append(line) else: return list
def _to_hosts(list): hosts = [] for line in list: kvp = line.split('|') hosts.append(kvp[1]) return hosts
def _to_passwords(list): passwords = {} for line in list: kvp = line.split('|') passwords[kvp[1]] = kvp[2] return passwords# '''#def new_user(username,admin='no',comment="No comment provided"):# log_action("New User (%s): %s" % (username,comment))# passdef exists(path): with settings(warn_only=True): return run('test -e %s ' % path)
def hello(name="world!"): print("Hello %s! " % name) run("uname -r",pty=False,combine_stderr=True)
#################################################################when I run the fab as below the prompt information as below.
***@MyUbuntu:~/test# grep 160.171 server.db |fab host:- helloeth0|10.250.160.171|ABC|test
['10.250.160.171']{'10.250.160.171': 'ABC'}[10.250.160.171] Executing task 'hello'Hello world!! [10.250.160.171] run: uname -rDEBUG:paramiko.transport:starting thread (client mode): 0x436768d0LINFO:paramiko.transport:Connected (version 2.0, client OpenSSH_5.3)DEBUG:paramiko.transport:kex algos:['diffie-hellman-group-exchange-sha256', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-***@lysator.liu.se'] server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-***@lysator.liu.se'] client mac:['hmac-md5', 'hmac-sha1', 'umac-***@openssh.com', 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-ripemd160', 'hmac-***@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'umac-***@openssh.com', 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-ripemd160', 'hmac-***@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', '***@openssh.com'] server compress:['none', '***@openssh.com'] client lang:[''] server lang:[''] kex follows?FalseDEBUG:paramiko.transport:Ciphers agreed: local=aes128-ctr, remote=aes128-ctrDEBUG:paramiko.transport:using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote noneDEBUG:paramiko.transport:Switch to new keys ...DEBUG:paramiko.transport:Trying discovered key 865642cf225227d9781b12554e2ce4d9 in /root/.ssh/id_rsaDEBUG:paramiko.transport:userauth is OKI[10.250.160.171] Login password for 'root': DEBUG:paramiko.transport:EOF in transport thread
Recently, I use fab to deploy some middleware or run some command on remote server. but even if I specified the env.password(s)¡£ when I run the fab, still prompt me to provide the password.
any ideas or suggestion?
The code like below import sys,os,timefrom fabric.api import *from fabric.api import local,outputoutput['output']=Trueimport fabricimport logging
logging.basicConfig(level=logging.DEBUG)def host(str=''): if str == '-': list = _to_list(sys.stdin) else: list = str.split('\n') env.hosts = _to_hosts(list) print env.hosts #print "Here OOOOOOO" env.passwords = _to_passwords(list) #netifs = _to_netifs(list) print env.passwords
#env.password={'10.150.110.171':'TVLE800G'}
def _to_list(handle): list = [] while True: line = handle.readline().strip() print line if line: list.append(line) else: return list
def _to_hosts(list): hosts = [] for line in list: kvp = line.split('|') hosts.append(kvp[1]) return hosts
def _to_passwords(list): passwords = {} for line in list: kvp = line.split('|') passwords[kvp[1]] = kvp[2] return passwords# '''#def new_user(username,admin='no',comment="No comment provided"):# log_action("New User (%s): %s" % (username,comment))# passdef exists(path): with settings(warn_only=True): return run('test -e %s ' % path)
def hello(name="world!"): print("Hello %s! " % name) run("uname -r",pty=False,combine_stderr=True)
#################################################################when I run the fab as below the prompt information as below.
***@MyUbuntu:~/test# grep 160.171 server.db |fab host:- helloeth0|10.250.160.171|ABC|test
['10.250.160.171']{'10.250.160.171': 'ABC'}[10.250.160.171] Executing task 'hello'Hello world!! [10.250.160.171] run: uname -rDEBUG:paramiko.transport:starting thread (client mode): 0x436768d0LINFO:paramiko.transport:Connected (version 2.0, client OpenSSH_5.3)DEBUG:paramiko.transport:kex algos:['diffie-hellman-group-exchange-sha256', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-***@lysator.liu.se'] server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-***@lysator.liu.se'] client mac:['hmac-md5', 'hmac-sha1', 'umac-***@openssh.com', 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-ripemd160', 'hmac-***@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'umac-***@openssh.com', 'hmac-sha2-256', 'hmac-sha2-512', 'hmac-ripemd160', 'hmac-***@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', '***@openssh.com'] server compress:['none', '***@openssh.com'] client lang:[''] server lang:[''] kex follows?FalseDEBUG:paramiko.transport:Ciphers agreed: local=aes128-ctr, remote=aes128-ctrDEBUG:paramiko.transport:using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote noneDEBUG:paramiko.transport:Switch to new keys ...DEBUG:paramiko.transport:Trying discovered key 865642cf225227d9781b12554e2ce4d9 in /root/.ssh/id_rsaDEBUG:paramiko.transport:userauth is OKI[10.250.160.171] Login password for 'root': DEBUG:paramiko.transport:EOF in transport thread