Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
89c01303
Commit
89c01303
authored
Apr 23, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'integration' of
https://github.com/cocoy/ansible
into cocoy-integration
parents
bced4c9d
c844a2d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
1 deletions
+29
-1
lib/ansible/connection.py
+29
-1
No files found.
lib/ansible/connection.py
View file @
89c01303
...
...
@@ -37,6 +37,8 @@ with warnings.catch_warnings():
################################################
class
Connection
(
object
):
''' Handles abstract connections to remote hosts '''
...
...
@@ -74,16 +76,42 @@ class ParamikoConnection(object):
self
.
port
=
self
.
runner
.
remote_port
def
_get_conn
(
self
):
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
:
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
)
except
IOError
,
e
:
raise
errors
.
AnsibleConnectionFailed
(
str
(
e
))
if
'hostname'
in
credentials
:
self
.
host
=
credentials
[
'hostname'
]
if
'port'
in
credentials
:
self
.
port
=
credentials
[
'port'
]
if
'user'
in
credentials
:
user
=
credentials
[
'user'
]
if
'identityfile'
in
credentials
:
keypair
=
credentials
[
'identityfile'
]
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
try
:
ssh
.
connect
(
self
.
host
,
username
=
self
.
runner
.
remote_
user
,
username
=
user
,
allow_agent
=
True
,
look_for_keys
=
True
,
password
=
self
.
runner
.
remote_pass
,
key_filename
=
keypair
,
timeout
=
self
.
runner
.
timeout
,
port
=
self
.
port
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment