|
|
|
|
@ -76,29 +76,29 @@ class ParamikoConnection(object):
|
|
|
|
|
self.port = self.runner.remote_port
|
|
|
|
|
|
|
|
|
|
def _get_conn(self):
|
|
|
|
|
credentials = {}
|
|
|
|
|
user = self.runner.remote_user
|
|
|
|
|
keypair = None
|
|
|
|
|
credentials = {}
|
|
|
|
|
user = self.runner.remote_user
|
|
|
|
|
keypair = None
|
|
|
|
|
|
|
|
|
|
# Read file ~/.ssh/config, get data hostname, keyfile, port, etc
|
|
|
|
|
# This overrides the ansible defined username,hostname and port
|
|
|
|
|
try:
|
|
|
|
|
# Read file ~/.ssh/config, get data hostname, keyfile, port, etc
|
|
|
|
|
# This overrides the ansible defined username,hostname and port
|
|
|
|
|
try:
|
|
|
|
|
ssh_config = paramiko.SSHConfig()
|
|
|
|
|
config_file = ('~/.ssh/config')
|
|
|
|
|
if os.path.exists(os.path.expanduser(config_file)):
|
|
|
|
|
ssh_config.parse(open(os.path.expanduser(config_file)))
|
|
|
|
|
credentials = ssh_config.lookup(self.host)
|
|
|
|
|
config_file = ('~/.ssh/config')
|
|
|
|
|
if os.path.exists(os.path.expanduser(config_file)):
|
|
|
|
|
ssh_config.parse(open(os.path.expanduser(config_file)))
|
|
|
|
|
credentials = ssh_config.lookup(self.host)
|
|
|
|
|
|
|
|
|
|
except IOError,e:
|
|
|
|
|
raise errors.AnsibleConnectionFailed(str(e))
|
|
|
|
|
|
|
|
|
|
if 'hostname' in credentials:
|
|
|
|
|
if 'hostname' in credentials:
|
|
|
|
|
self.host = credentials['hostname']
|
|
|
|
|
if 'port' in credentials:
|
|
|
|
|
if 'port' in credentials:
|
|
|
|
|
self.port = int(credentials['port'])
|
|
|
|
|
if 'user' in credentials:
|
|
|
|
|
if 'user' in credentials:
|
|
|
|
|
user = credentials['user']
|
|
|
|
|
if 'identityfile' in credentials:
|
|
|
|
|
if 'identityfile' in credentials:
|
|
|
|
|
keypair = credentials['identityfile']
|
|
|
|
|
|
|
|
|
|
ssh = paramiko.SSHClient()
|
|
|
|
|
@ -111,7 +111,7 @@ class ParamikoConnection(object):
|
|
|
|
|
allow_agent=True,
|
|
|
|
|
look_for_keys=True,
|
|
|
|
|
password=self.runner.remote_pass,
|
|
|
|
|
key_filename=keypair,
|
|
|
|
|
key_filename=keypair,
|
|
|
|
|
timeout=self.runner.timeout,
|
|
|
|
|
port=self.port
|
|
|
|
|
)
|
|
|
|
|
|