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
4168a3e8
Commit
4168a3e8
authored
Nov 03, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9462 from tkinz27/paramiko_keepalive
Setting keepalive option before opening session
parents
9c619863
3e992b58
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
lib/ansible/runner/connection_plugins/paramiko_ssh.py
+14
-14
No files found.
lib/ansible/runner/connection_plugins/paramiko_ssh.py
View file @
4168a3e8
...
@@ -40,10 +40,10 @@ from ansible.callbacks import vvv
...
@@ -40,10 +40,10 @@ from ansible.callbacks import vvv
from
ansible
import
errors
from
ansible
import
errors
from
ansible
import
utils
from
ansible
import
utils
from
ansible
import
constants
as
C
from
ansible
import
constants
as
C
AUTHENTICITY_MSG
=
"""
AUTHENTICITY_MSG
=
"""
paramiko: The authenticity of host '
%
s' can't be established.
paramiko: The authenticity of host '
%
s' can't be established.
The
%
s key fingerprint is
%
s.
The
%
s key fingerprint is
%
s.
Are you sure you want to continue connecting (yes/no)?
Are you sure you want to continue connecting (yes/no)?
"""
"""
...
@@ -67,7 +67,7 @@ class MyAddPolicy(object):
...
@@ -67,7 +67,7 @@ class MyAddPolicy(object):
local L{HostKeys} object, and saving it. This is used by L{SSHClient}.
local L{HostKeys} object, and saving it. This is used by L{SSHClient}.
"""
"""
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
def
missing_host_key
(
self
,
client
,
hostname
,
key
):
def
missing_host_key
(
self
,
client
,
hostname
,
key
):
...
@@ -81,7 +81,7 @@ class MyAddPolicy(object):
...
@@ -81,7 +81,7 @@ class MyAddPolicy(object):
sys
.
stdin
=
self
.
runner
.
_new_stdin
sys
.
stdin
=
self
.
runner
.
_new_stdin
fingerprint
=
hexlify
(
key
.
get_fingerprint
())
fingerprint
=
hexlify
(
key
.
get_fingerprint
())
ktype
=
key
.
get_name
()
ktype
=
key
.
get_name
()
# clear out any premature input on sys.stdin
# clear out any premature input on sys.stdin
tcflush
(
sys
.
stdin
,
TCIFLUSH
)
tcflush
(
sys
.
stdin
,
TCIFLUSH
)
...
@@ -103,7 +103,7 @@ class MyAddPolicy(object):
...
@@ -103,7 +103,7 @@ class MyAddPolicy(object):
# host keys are actually saved in close() function below
# host keys are actually saved in close() function below
# in order to control ordering.
# in order to control ordering.
# keep connection objects on a per host basis to avoid repeated attempts to reconnect
# keep connection objects on a per host basis to avoid repeated attempts to reconnect
...
@@ -145,7 +145,7 @@ class Connection(object):
...
@@ -145,7 +145,7 @@ class Connection(object):
vvv
(
"ESTABLISH CONNECTION FOR USER:
%
s on PORT
%
s TO
%
s"
%
(
self
.
user
,
self
.
port
,
self
.
host
),
host
=
self
.
host
)
vvv
(
"ESTABLISH CONNECTION FOR USER:
%
s on PORT
%
s TO
%
s"
%
(
self
.
user
,
self
.
port
,
self
.
host
),
host
=
self
.
host
)
ssh
=
paramiko
.
SSHClient
()
ssh
=
paramiko
.
SSHClient
()
self
.
keyfile
=
os
.
path
.
expanduser
(
"~/.ssh/known_hosts"
)
self
.
keyfile
=
os
.
path
.
expanduser
(
"~/.ssh/known_hosts"
)
if
C
.
HOST_KEY_CHECKING
:
if
C
.
HOST_KEY_CHECKING
:
...
@@ -194,8 +194,8 @@ class Connection(object):
...
@@ -194,8 +194,8 @@ class Connection(object):
try
:
try
:
chan
=
self
.
ssh
.
get_transport
()
.
open_session
()
self
.
ssh
.
get_transport
()
.
set_keepalive
(
5
)
self
.
ssh
.
get_transport
()
.
set_keepalive
(
5
)
chan
=
self
.
ssh
.
get_transport
()
.
open_session
()
except
Exception
,
e
:
except
Exception
,
e
:
...
@@ -318,7 +318,7 @@ class Connection(object):
...
@@ -318,7 +318,7 @@ class Connection(object):
def
_any_keys_added
(
self
):
def
_any_keys_added
(
self
):
added_any
=
False
added_any
=
False
for
hostname
,
keys
in
self
.
ssh
.
_host_keys
.
iteritems
():
for
hostname
,
keys
in
self
.
ssh
.
_host_keys
.
iteritems
():
for
keytype
,
key
in
keys
.
iteritems
():
for
keytype
,
key
in
keys
.
iteritems
():
added_this_time
=
getattr
(
key
,
'_added_by_ansible_this_time'
,
False
)
added_this_time
=
getattr
(
key
,
'_added_by_ansible_this_time'
,
False
)
...
@@ -327,9 +327,9 @@ class Connection(object):
...
@@ -327,9 +327,9 @@ class Connection(object):
return
False
return
False
def
_save_ssh_host_keys
(
self
,
filename
):
def
_save_ssh_host_keys
(
self
,
filename
):
'''
'''
not using the paramiko save_ssh_host_keys function as we want to add new SSH keys at the bottom so folks
not using the paramiko save_ssh_host_keys function as we want to add new SSH keys at the bottom so folks
don't complain about it :)
don't complain about it :)
'''
'''
if
not
self
.
_any_keys_added
():
if
not
self
.
_any_keys_added
():
...
@@ -372,7 +372,7 @@ class Connection(object):
...
@@ -372,7 +372,7 @@ class Connection(object):
if
C
.
HOST_KEY_CHECKING
and
C
.
PARAMIKO_RECORD_HOST_KEYS
and
self
.
_any_keys_added
():
if
C
.
HOST_KEY_CHECKING
and
C
.
PARAMIKO_RECORD_HOST_KEYS
and
self
.
_any_keys_added
():
# add any new SSH host keys -- warning -- this could be slow
# add any new SSH host keys -- warning -- this could be slow
lockfile
=
self
.
keyfile
.
replace
(
"known_hosts"
,
".known_hosts.lock"
)
lockfile
=
self
.
keyfile
.
replace
(
"known_hosts"
,
".known_hosts.lock"
)
dirname
=
os
.
path
.
dirname
(
self
.
keyfile
)
dirname
=
os
.
path
.
dirname
(
self
.
keyfile
)
if
not
os
.
path
.
exists
(
dirname
):
if
not
os
.
path
.
exists
(
dirname
):
os
.
makedirs
(
dirname
)
os
.
makedirs
(
dirname
)
...
@@ -414,4 +414,4 @@ class Connection(object):
...
@@ -414,4 +414,4 @@ class Connection(object):
fcntl
.
lockf
(
KEY_LOCK
,
fcntl
.
LOCK_UN
)
fcntl
.
lockf
(
KEY_LOCK
,
fcntl
.
LOCK_UN
)
self
.
ssh
.
close
()
self
.
ssh
.
close
()
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