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
713809b6
Commit
713809b6
authored
Sep 23, 2015
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'amenonsen-ssh-indata' into devel
parents
c9a00422
587054db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
9 deletions
+24
-9
lib/ansible/plugins/connection/ssh.py
+24
-9
No files found.
lib/ansible/plugins/connection/ssh.py
View file @
713809b6
...
...
@@ -436,6 +436,13 @@ class Connection(ConnectionBase):
for
fd
in
rpipes
:
fcntl
.
fcntl
(
fd
,
fcntl
.
F_SETFL
,
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFL
)
|
os
.
O_NONBLOCK
)
# If we can send initial data without waiting for anything, we do so
# before we call select.
if
states
[
state
]
==
'ready_to_send'
and
in_data
:
self
.
_send_initial_data
(
stdin
,
in_data
)
state
+=
1
while
True
:
rfd
,
wfd
,
efd
=
select
.
select
(
rpipes
,
[],
rpipes
,
timeout
)
...
...
@@ -518,18 +525,11 @@ class Connection(ConnectionBase):
# Once we're sure that the privilege escalation prompt, if any, has
# been dealt with, we can send any initial data and start waiting
# for output. (Note that we have to close the process's stdin here,
# otherwise, for example, "sftp -b -" will just hang forever waiting
# for more commands.)
# for output.
if
states
[
state
]
==
'ready_to_send'
:
if
in_data
:
self
.
_display
.
debug
(
'Sending initial data (
%
d bytes)'
%
len
(
in_data
))
try
:
stdin
.
write
(
in_data
)
stdin
.
close
()
except
(
OSError
,
IOError
):
raise
AnsibleConnectionFailure
(
'SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh'
)
self
.
_send_initial_data
(
stdin
,
in_data
)
state
+=
1
# Now we just wait for the process to exit. Output is already being
...
...
@@ -567,6 +567,21 @@ class Connection(ConnectionBase):
return
(
p
.
returncode
,
stdout
,
stderr
)
def
_send_initial_data
(
self
,
fh
,
in_data
):
'''
Writes initial data to the stdin filehandle of the subprocess and closes
it. (The handle must be closed; otherwise, for example, "sftp -b -" will
just hang forever waiting for more commands.)
'''
self
.
_display
.
debug
(
'Sending initial data (
%
d bytes)'
%
len
(
in_data
))
try
:
fh
.
write
(
in_data
)
fh
.
close
()
except
(
OSError
,
IOError
):
raise
AnsibleConnectionFailure
(
'SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh'
)
# This is a separate method because we need to do the same thing for stdout
# and stderr.
...
...
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