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
33196ec1
Commit
33196ec1
authored
Nov 24, 2012
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1669 from dagwieers/ssh-tcgetattr2
Use proper pseudo-tty's instead of pipes when using subprocess
parents
ac09b47e
7192eb30
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
lib/ansible/runner/connection_plugins/ssh.py
+13
-4
No files found.
lib/ansible/runner/connection_plugins/ssh.py
View file @
33196ec1
...
...
@@ -97,8 +97,17 @@ class Connection(object):
ssh_cmd
.
append
(
'/bin/sh -c '
+
pipes
.
quote
(
cmd
))
vvv
(
"EXEC
%
s"
%
ssh_cmd
,
host
=
self
.
host
)
p
=
subprocess
.
Popen
(
ssh_cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
try
:
# Make sure stdin is a proper (pseudo) pty to avoid: tcgetattr errors
import
pty
master
,
slave
=
pty
.
openpty
()
p
=
subprocess
.
Popen
(
ssh_cmd
,
stdin
=
slave
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
stdin
=
os
.
fdopen
(
master
,
'w'
,
0
)
except
:
p
=
subprocess
.
Popen
(
ssh_cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
stdin
=
p
.
stdin
self
.
_send_password
()
...
...
@@ -117,7 +126,7 @@ class Connection(object):
else
:
stdout
=
p
.
communicate
()
raise
errors
.
AnsibleError
(
'ssh connection error waiting for sudo password prompt'
)
p
.
stdin
.
write
(
self
.
runner
.
sudo_pass
+
'
\n
'
)
stdin
.
write
(
self
.
runner
.
sudo_pass
+
'
\n
'
)
fcntl
.
fcntl
(
p
.
stdout
,
fcntl
.
F_SETFL
,
fcntl
.
fcntl
(
p
.
stdout
,
fcntl
.
F_GETFL
)
&
~
os
.
O_NONBLOCK
)
# We can't use p.communicate here because the ControlMaster may have stdout open as well
...
...
@@ -132,7 +141,7 @@ class Connection(object):
break
elif
p
.
poll
()
is
not
None
:
break
p
.
stdin
.
close
()
# close stdin after we read from stdout (see also issue #848)
stdin
.
close
()
# close stdin after we read from stdout (see also issue #848)
if
p
.
returncode
!=
0
and
stdout
.
find
(
'Bad configuration option: ControlPersist'
)
!=
-
1
:
raise
errors
.
AnsibleError
(
'using -c ssh on certain older ssh versions may not support ControlPersist, set ANSIBLE_SSH_ARGS="" (or ansible_ssh_args in the config file) before running again'
)
...
...
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