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
4eb7206f
Commit
4eb7206f
authored
Jun 26, 2012
by
Dane Summers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added ability to ovverride all ssh settings via ANSIBLE_SSH_ARGS
parent
53360d6c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
lib/ansible/runner/connection/ssh.py
+10
-10
No files found.
lib/ansible/runner/connection/ssh.py
View file @
4eb7206f
...
...
@@ -39,12 +39,7 @@ class SSHConnection(object):
def
connect
(
self
):
''' connect to the remote host '''
self
.
common_args
=
[
"-o"
,
"StrictHostKeyChecking=no"
]
if
self
.
port
is
not
None
:
self
.
common_args
+=
[
"-o"
,
"Port=
%
d"
%
(
self
.
port
)]
if
self
.
runner
.
private_key_file
is
not
None
:
self
.
common_args
+=
[
"-o"
,
"IdentityFile="
+
self
.
runner
.
private_key_file
]
self
.
common_args
=
[]
extra_args
=
os
.
getenv
(
"ANSIBLE_SSH_ARGS"
,
None
)
if
extra_args
is
not
None
:
self
.
common_args
+=
shlex
.
split
(
extra_args
)
...
...
@@ -52,14 +47,19 @@ class SSHConnection(object):
self
.
common_args
+=
[
"-o"
,
"ControlMaster=auto"
,
"-o"
,
"ControlPersist=60s"
,
"-o"
,
"ControlPath=/tmp/ansible-ssh-
%
h-
%
p-
%
r"
]
self
.
userhost
=
"
%
s@
%
s"
%
(
self
.
runner
.
remote_user
,
self
.
host
)
self
.
common_args
+=
[
"-o"
,
"StrictHostKeyChecking=no"
]
if
self
.
port
is
not
None
:
self
.
common_args
+=
[
"-o"
,
"Port=
%
d"
%
(
self
.
port
)]
if
self
.
runner
.
private_key_file
is
not
None
:
self
.
common_args
+=
[
"-o"
,
"IdentityFile="
+
self
.
runner
.
private_key_file
]
self
.
common_args
+=
[
"-o"
,
"User="
+
self
.
runner
.
remote_user
]
return
self
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
,
sudoable
=
False
):
''' run a command on the remote host '''
ssh_cmd
=
[
"ssh"
,
"-tt"
,
"-q"
]
+
self
.
common_args
+
[
self
.
user
host
]
ssh_cmd
=
[
"ssh"
,
"-tt"
,
"-q"
]
+
self
.
common_args
+
[
self
.
host
]
if
self
.
runner
.
sudo
and
sudoable
:
# Rather than detect if sudo wants a password this time, -k makes
# sudo always ask for a password if one is required. The "--"
...
...
@@ -117,7 +117,7 @@ class SSHConnection(object):
''' transfer a file from local to remote '''
if
not
os
.
path
.
exists
(
in_path
):
raise
errors
.
AnsibleFileNotFound
(
"file or module does not exist:
%
s"
%
in_path
)
sftp_cmd
=
[
"sftp"
]
+
self
.
common_args
+
[
self
.
user
host
]
sftp_cmd
=
[
"sftp"
]
+
self
.
common_args
+
[
self
.
host
]
p
=
subprocess
.
Popen
(
sftp_cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
p
.
communicate
(
"put
%
s
%
s
\n
"
%
(
in_path
,
out_path
))
...
...
@@ -128,7 +128,7 @@ class SSHConnection(object):
''' fetch a file from remote to local '''
if
not
os
.
path
.
exists
(
in_path
):
raise
errors
.
AnsibleFileNotFound
(
"file or module does not exist:
%
s"
%
in_path
)
sftp_cmd
=
[
"sftp"
]
+
self
.
common_args
+
[
self
.
user
host
]
sftp_cmd
=
[
"sftp"
]
+
self
.
common_args
+
[
self
.
host
]
p
=
subprocess
.
Popen
(
sftp_cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
p
.
communicate
(
"get
%
s
%
s
\n
"
%
(
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