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
233aae58
Commit
233aae58
authored
Jan 16, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverting paramiko_ssh/alt changes from yesterday
parent
87e7b9e5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
20 deletions
+20
-20
lib/ansible/runner/__init__.py
+2
-2
lib/ansible/runner/connection_plugins/paramiko_alt.py
+12
-6
lib/ansible/runner/connection_plugins/paramiko_ssh.py
+6
-12
No files found.
lib/ansible/runner/__init__.py
View file @
233aae58
...
@@ -441,7 +441,7 @@ class Runner(object):
...
@@ -441,7 +441,7 @@ class Runner(object):
host_variables
=
self
.
inventory
.
get_variables
(
host
)
host_variables
=
self
.
inventory
.
get_variables
(
host
)
host_connection
=
host_variables
.
get
(
'ansible_connection'
,
self
.
transport
)
host_connection
=
host_variables
.
get
(
'ansible_connection'
,
self
.
transport
)
if
host_connection
in
[
'paramiko'
,
'paramiko_
old
'
,
'ssh'
,
'ssh_old'
,
'accelerate'
]:
if
host_connection
in
[
'paramiko'
,
'paramiko_
alt
'
,
'ssh'
,
'ssh_old'
,
'accelerate'
]:
port
=
host_variables
.
get
(
'ansible_ssh_port'
,
self
.
remote_port
)
port
=
host_variables
.
get
(
'ansible_ssh_port'
,
self
.
remote_port
)
if
port
is
None
:
if
port
is
None
:
port
=
C
.
DEFAULT_REMOTE_PORT
port
=
C
.
DEFAULT_REMOTE_PORT
...
@@ -628,7 +628,7 @@ class Runner(object):
...
@@ -628,7 +628,7 @@ class Runner(object):
if
not
self
.
accelerate_port
:
if
not
self
.
accelerate_port
:
self
.
accelerate_port
=
C
.
ACCELERATE_PORT
self
.
accelerate_port
=
C
.
ACCELERATE_PORT
if
actual_transport
in
[
'paramiko'
,
'paramiko_
old
'
,
'ssh'
,
'ssh_old'
,
'accelerate'
]:
if
actual_transport
in
[
'paramiko'
,
'paramiko_
alt
'
,
'ssh'
,
'ssh_old'
,
'accelerate'
]:
actual_port
=
inject
.
get
(
'ansible_ssh_port'
,
port
)
actual_port
=
inject
.
get
(
'ansible_ssh_port'
,
port
)
# the delegated host may have different SSH port configured, etc
# the delegated host may have different SSH port configured, etc
...
...
lib/ansible/runner/connection_plugins/paramiko_
old
.py
→
lib/ansible/runner/connection_plugins/paramiko_
alt
.py
View file @
233aae58
...
@@ -121,7 +121,7 @@ class Connection(object):
...
@@ -121,7 +121,7 @@ class Connection(object):
self
.
user
=
user
self
.
user
=
user
self
.
password
=
password
self
.
password
=
password
self
.
private_key_file
=
private_key_file
self
.
private_key_file
=
private_key_file
self
.
has_pipelining
=
Fals
e
self
.
has_pipelining
=
Tru
e
def
_cache_key
(
self
):
def
_cache_key
(
self
):
return
"
%
s__
%
s__"
%
(
self
.
host
,
self
.
user
)
return
"
%
s__
%
s__"
%
(
self
.
host
,
self
.
user
)
...
@@ -179,9 +179,6 @@ class Connection(object):
...
@@ -179,9 +179,6 @@ class Connection(object):
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
,
sudoable
=
False
,
executable
=
'/bin/sh'
,
in_data
=
None
):
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
,
sudoable
=
False
,
executable
=
'/bin/sh'
,
in_data
=
None
):
''' run a command on the remote host '''
''' run a command on the remote host '''
if
in_data
:
raise
errors
.
AnsibleError
(
"Internal Error: this module does not support optimized module pipelining"
)
bufsize
=
4096
bufsize
=
4096
try
:
try
:
chan
=
self
.
ssh
.
get_transport
()
.
open_session
()
chan
=
self
.
ssh
.
get_transport
()
.
open_session
()
...
@@ -191,12 +188,12 @@ class Connection(object):
...
@@ -191,12 +188,12 @@ class Connection(object):
msg
+=
":
%
s"
%
str
(
e
)
msg
+=
":
%
s"
%
str
(
e
)
raise
errors
.
AnsibleConnectionFailed
(
msg
)
raise
errors
.
AnsibleConnectionFailed
(
msg
)
if
not
self
.
runner
.
sudo
or
not
sudoable
:
if
not
self
.
runner
.
sudo
or
not
sudoable
or
in_data
:
if
executable
:
if
executable
:
quoted_command
=
executable
+
' -c '
+
pipes
.
quote
(
cmd
)
quoted_command
=
executable
+
' -c '
+
pipes
.
quote
(
cmd
)
else
:
else
:
quoted_command
=
cmd
quoted_command
=
cmd
vvv
(
"EXEC
%
s"
%
quoted_command
,
host
=
self
.
host
)
vvv
(
"EXEC
ALT no-tty
%
s"
%
quoted_command
,
host
=
self
.
host
)
chan
.
exec_command
(
quoted_command
)
chan
.
exec_command
(
quoted_command
)
else
:
else
:
# sudo usually requires a PTY (cf. requiretty option), therefore
# sudo usually requires a PTY (cf. requiretty option), therefore
...
@@ -227,8 +224,17 @@ class Connection(object):
...
@@ -227,8 +224,17 @@ class Connection(object):
except
socket
.
timeout
:
except
socket
.
timeout
:
raise
errors
.
AnsibleError
(
'ssh timed out waiting for sudo.
\n
'
+
sudo_output
)
raise
errors
.
AnsibleError
(
'ssh timed out waiting for sudo.
\n
'
+
sudo_output
)
if
in_data
:
try
:
stdin
=
chan
.
makefile
(
'wb'
)
stdin
.
write
(
in_data
)
chan
.
shutdown_write
()
except
Exception
,
e
:
raise
errors
.
AnsibleError
(
'SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh.'
)
stdout
=
''
.
join
(
chan
.
makefile
(
'rb'
,
bufsize
))
stdout
=
''
.
join
(
chan
.
makefile
(
'rb'
,
bufsize
))
stderr
=
''
.
join
(
chan
.
makefile_stderr
(
'rb'
,
bufsize
))
stderr
=
''
.
join
(
chan
.
makefile_stderr
(
'rb'
,
bufsize
))
return
(
chan
.
recv_exit_status
(),
''
,
stdout
,
stderr
)
return
(
chan
.
recv_exit_status
(),
''
,
stdout
,
stderr
)
def
put_file
(
self
,
in_path
,
out_path
):
def
put_file
(
self
,
in_path
,
out_path
):
...
...
lib/ansible/runner/connection_plugins/paramiko_ssh.py
View file @
233aae58
...
@@ -121,7 +121,7 @@ class Connection(object):
...
@@ -121,7 +121,7 @@ class Connection(object):
self
.
user
=
user
self
.
user
=
user
self
.
password
=
password
self
.
password
=
password
self
.
private_key_file
=
private_key_file
self
.
private_key_file
=
private_key_file
self
.
has_pipelining
=
Tru
e
self
.
has_pipelining
=
Fals
e
def
_cache_key
(
self
):
def
_cache_key
(
self
):
return
"
%
s__
%
s__"
%
(
self
.
host
,
self
.
user
)
return
"
%
s__
%
s__"
%
(
self
.
host
,
self
.
user
)
...
@@ -179,6 +179,9 @@ class Connection(object):
...
@@ -179,6 +179,9 @@ class Connection(object):
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
,
sudoable
=
False
,
executable
=
'/bin/sh'
,
in_data
=
None
):
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
,
sudoable
=
False
,
executable
=
'/bin/sh'
,
in_data
=
None
):
''' run a command on the remote host '''
''' run a command on the remote host '''
if
in_data
:
raise
errors
.
AnsibleError
(
"Internal Error: this module does not support optimized module pipelining"
)
bufsize
=
4096
bufsize
=
4096
try
:
try
:
chan
=
self
.
ssh
.
get_transport
()
.
open_session
()
chan
=
self
.
ssh
.
get_transport
()
.
open_session
()
...
@@ -188,12 +191,12 @@ class Connection(object):
...
@@ -188,12 +191,12 @@ class Connection(object):
msg
+=
":
%
s"
%
str
(
e
)
msg
+=
":
%
s"
%
str
(
e
)
raise
errors
.
AnsibleConnectionFailed
(
msg
)
raise
errors
.
AnsibleConnectionFailed
(
msg
)
if
not
self
.
runner
.
sudo
or
not
sudoable
or
in_data
:
if
not
self
.
runner
.
sudo
or
not
sudoable
:
if
executable
:
if
executable
:
quoted_command
=
executable
+
' -c '
+
pipes
.
quote
(
cmd
)
quoted_command
=
executable
+
' -c '
+
pipes
.
quote
(
cmd
)
else
:
else
:
quoted_command
=
cmd
quoted_command
=
cmd
vvv
(
"EXEC
ALT no-tty
%
s"
%
quoted_command
,
host
=
self
.
host
)
vvv
(
"EXEC
%
s"
%
quoted_command
,
host
=
self
.
host
)
chan
.
exec_command
(
quoted_command
)
chan
.
exec_command
(
quoted_command
)
else
:
else
:
# sudo usually requires a PTY (cf. requiretty option), therefore
# sudo usually requires a PTY (cf. requiretty option), therefore
...
@@ -224,17 +227,8 @@ class Connection(object):
...
@@ -224,17 +227,8 @@ class Connection(object):
except
socket
.
timeout
:
except
socket
.
timeout
:
raise
errors
.
AnsibleError
(
'ssh timed out waiting for sudo.
\n
'
+
sudo_output
)
raise
errors
.
AnsibleError
(
'ssh timed out waiting for sudo.
\n
'
+
sudo_output
)
if
in_data
:
try
:
stdin
=
chan
.
makefile
(
'wb'
)
stdin
.
write
(
in_data
)
chan
.
shutdown_write
()
except
Exception
,
e
:
raise
errors
.
AnsibleError
(
'SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh.'
)
stdout
=
''
.
join
(
chan
.
makefile
(
'rb'
,
bufsize
))
stdout
=
''
.
join
(
chan
.
makefile
(
'rb'
,
bufsize
))
stderr
=
''
.
join
(
chan
.
makefile_stderr
(
'rb'
,
bufsize
))
stderr
=
''
.
join
(
chan
.
makefile_stderr
(
'rb'
,
bufsize
))
return
(
chan
.
recv_exit_status
(),
''
,
stdout
,
stderr
)
return
(
chan
.
recv_exit_status
(),
''
,
stdout
,
stderr
)
def
put_file
(
self
,
in_path
,
out_path
):
def
put_file
(
self
,
in_path
,
out_path
):
...
...
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