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
74e4ccb5
Commit
74e4ccb5
authored
Dec 10, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "ssh_alt.py / decrease # of ssh roundtrips"
This reverts commit
7f8863f9
.
parent
f72bb8c7
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
49 additions
and
160 deletions
+49
-160
lib/ansible/runner/__init__.py
+20
-71
lib/ansible/runner/action_plugins/add_host.py
+1
-1
lib/ansible/runner/action_plugins/assemble.py
+0
-2
lib/ansible/runner/action_plugins/copy.py
+0
-2
lib/ansible/runner/action_plugins/debug.py
+1
-1
lib/ansible/runner/action_plugins/fail.py
+1
-1
lib/ansible/runner/action_plugins/group_by.py
+1
-1
lib/ansible/runner/action_plugins/include_vars.py
+1
-1
lib/ansible/runner/action_plugins/raw.py
+1
-1
lib/ansible/runner/action_plugins/script.py
+0
-2
lib/ansible/runner/action_plugins/set_fact.py
+1
-1
lib/ansible/runner/action_plugins/template.py
+0
-2
lib/ansible/runner/action_plugins/unarchive.py
+0
-2
lib/ansible/runner/connection_plugins/accelerate.py
+1
-5
lib/ansible/runner/connection_plugins/chroot.py
+1
-5
lib/ansible/runner/connection_plugins/fireball.py
+1
-5
lib/ansible/runner/connection_plugins/funcd.py
+1
-5
lib/ansible/runner/connection_plugins/jail.py
+1
-5
lib/ansible/runner/connection_plugins/local.py
+1
-5
lib/ansible/runner/connection_plugins/paramiko_ssh.py
+1
-5
lib/ansible/runner/connection_plugins/ssh.py
+1
-5
lib/ansible/runner/connection_plugins/ssh_alt.py
+14
-32
No files found.
lib/ansible/runner/__init__.py
View file @
74e4ccb5
...
@@ -286,7 +286,7 @@ class Runner(object):
...
@@ -286,7 +286,7 @@ class Runner(object):
def
_execute_module
(
self
,
conn
,
tmp
,
module_name
,
args
,
def
_execute_module
(
self
,
conn
,
tmp
,
module_name
,
args
,
async_jid
=
None
,
async_module
=
None
,
async_limit
=
None
,
inject
=
None
,
persist_files
=
False
,
complex_args
=
None
):
async_jid
=
None
,
async_module
=
None
,
async_limit
=
None
,
inject
=
None
,
persist_files
=
False
,
complex_args
=
None
):
'''
transfer and run a module along with its arguments on the remote side
'''
'''
runs a module that has already been transferred
'''
# hack to support fireball mode
# hack to support fireball mode
if
module_name
==
'fireball'
:
if
module_name
==
'fireball'
:
...
@@ -294,24 +294,12 @@ class Runner(object):
...
@@ -294,24 +294,12 @@ class Runner(object):
if
'port'
not
in
args
:
if
'port'
not
in
args
:
args
+=
" port=
%
s"
%
C
.
ZEROMQ_PORT
args
+=
" port=
%
s"
%
C
.
ZEROMQ_PORT
(
(
remote_module_path
,
module_style
,
shebang
)
=
self
.
_copy_module
(
conn
,
tmp
,
module_name
,
args
,
inject
,
complex_args
)
module_style
,
shebang
,
module_data
)
=
self
.
_configure_module
(
conn
,
module_name
,
args
,
inject
,
complex_args
)
# a remote tmp path may be necessary and not already created
if
self
.
_late_needs_tmp_path
(
conn
,
tmp
,
module_style
):
tmp
=
self
.
_make_tmp_path
(
conn
)
remote_module_path
=
os
.
path
.
join
(
tmp
,
module_name
)
if
not
conn
.
has_pipelining
:
self
.
_transfer_str
(
conn
,
tmp
,
module_name
,
module_data
)
environment_string
=
self
.
_compute_environment_string
(
inject
)
environment_string
=
self
.
_compute_environment_string
(
inject
)
if
tmp
.
find
(
"tmp"
)
!=
-
1
and
self
.
sudo
and
self
.
sudo_user
!=
'root'
:
cmd_mod
=
""
if
self
.
sudo
and
self
.
sudo_user
!=
'root'
:
# deal with possible umask issues once sudo'ed to other user
# deal with possible umask issues once sudo'ed to other user
cmd_chmod
=
"chmod a+r
%
s"
%
remote_module_path
cmd_chmod
=
"chmod a+r
%
s"
%
remote_module_path
self
.
_low_level_exec_command
(
conn
,
cmd_chmod
,
tmp
,
sudoable
=
False
)
self
.
_low_level_exec_command
(
conn
,
cmd_chmod
,
tmp
,
sudoable
=
False
)
...
@@ -355,9 +343,6 @@ class Runner(object):
...
@@ -355,9 +343,6 @@ class Runner(object):
if
not
shebang
:
if
not
shebang
:
raise
errors
.
AnsibleError
(
"module is missing interpreter line"
)
raise
errors
.
AnsibleError
(
"module is missing interpreter line"
)
if
conn
.
has_pipelining
:
cmd
=
""
cmd
=
" "
.
join
([
environment_string
.
strip
(),
shebang
.
replace
(
"#!"
,
""
)
.
strip
(),
cmd
])
cmd
=
" "
.
join
([
environment_string
.
strip
(),
shebang
.
replace
(
"#!"
,
""
)
.
strip
(),
cmd
])
cmd
=
cmd
.
strip
()
cmd
=
cmd
.
strip
()
...
@@ -372,16 +357,12 @@ class Runner(object):
...
@@ -372,16 +357,12 @@ class Runner(object):
# specified in the play, not the sudo_user
# specified in the play, not the sudo_user
sudoable
=
False
sudoable
=
False
in_data
=
None
res
=
self
.
_low_level_exec_command
(
conn
,
cmd
,
tmp
,
sudoable
=
sudoable
)
if
conn
.
has_pipelining
:
in_data
=
module_data
res
=
self
.
_low_level_exec_command
(
conn
,
cmd
,
tmp
,
sudoable
=
sudoable
,
in_data
=
in_data
)
if
self
.
sudo
and
self
.
sudo_user
!=
'root'
:
if
tmp
.
find
(
"tmp"
)
!=
-
1
and
not
C
.
DEFAULT_KEEP_REMOTE_FILES
and
not
persist_files
:
if
self
.
sudo
and
self
.
sudo_user
!=
'root'
:
# not sudoing to root, so maybe can't delete files as that other user
# not sudoing to root, so maybe can't delete files as that other user
# have to clean up temp files as original user in a second step
# have to clean up temp files as original user in a second step
if
tmp
.
find
(
"tmp"
)
!=
-
1
and
not
C
.
DEFAULT_KEEP_REMOTE_FILES
and
not
persist_files
:
cmd2
=
"rm -rf
%
s >/dev/null 2>&1"
%
tmp
cmd2
=
"rm -rf
%
s >/dev/null 2>&1"
%
tmp
self
.
_low_level_exec_command
(
conn
,
cmd2
,
tmp
,
sudoable
=
False
)
self
.
_low_level_exec_command
(
conn
,
cmd2
,
tmp
,
sudoable
=
False
)
...
@@ -689,8 +670,8 @@ class Runner(object):
...
@@ -689,8 +670,8 @@ class Runner(object):
return
ReturnData
(
host
=
host
,
comm_ok
=
False
,
result
=
result
)
return
ReturnData
(
host
=
host
,
comm_ok
=
False
,
result
=
result
)
tmp
=
''
tmp
=
''
# a
ction plugins may DECLARE via TRANSFERS_FILES = True that they need a remote tmp path working dir
# a
ll modules get a tempdir, action plugins get one unless they have NEEDS_TMPPATH set to False
if
self
.
_early_needs_tmp_path
(
module_name
,
handler
):
if
getattr
(
handler
,
'NEEDS_TMPPATH'
,
True
):
tmp
=
self
.
_make_tmp_path
(
conn
)
tmp
=
self
.
_make_tmp_path
(
conn
)
# render module_args and complex_args templates
# render module_args and complex_args templates
...
@@ -716,7 +697,7 @@ class Runner(object):
...
@@ -716,7 +697,7 @@ class Runner(object):
delay
=
float
(
delay
)
delay
=
float
(
delay
)
time
.
sleep
(
delay
)
time
.
sleep
(
delay
)
tmp
=
''
tmp
=
''
if
self
.
_early_needs_tmp_path
(
module_name
,
handler
):
if
getattr
(
handler
,
'NEEDS_TMPPATH'
,
True
):
tmp
=
self
.
_make_tmp_path
(
conn
)
tmp
=
self
.
_make_tmp_path
(
conn
)
result
=
handler
.
run
(
conn
,
tmp
,
module_name
,
module_args
,
inject
,
complex_args
)
result
=
handler
.
run
(
conn
,
tmp
,
module_name
,
module_args
,
inject
,
complex_args
)
result
.
result
[
'attempts'
]
=
x
result
.
result
[
'attempts'
]
=
x
...
@@ -772,29 +753,9 @@ class Runner(object):
...
@@ -772,29 +753,9 @@ class Runner(object):
self
.
callbacks
.
on_ok
(
host
,
data
)
self
.
callbacks
.
on_ok
(
host
,
data
)
return
result
return
result
def
_early_needs_tmp_path
(
self
,
module_name
,
handler
):
''' detect if a tmp path should be created before the handler is called '''
if
module_name
in
utils
.
plugins
.
action_loader
:
return
getattr
(
handler
,
'TRANSFERS_FILES'
,
False
)
# other modules never need tmp path at early stage
return
False
def
_late_needs_tmp_path
(
self
,
conn
,
tmp
,
module_style
):
if
tmp
.
find
(
"tmp"
)
!=
-
1
:
# tmp has already been created
return
False
if
not
conn
.
has_pipelining
:
# tmp is necessary to store the module source code
return
True
if
module_style
!=
"new"
:
# even when conn has pipelining, old style modules need tmp to store arguments
return
True
return
False
# *****************************************************
# *****************************************************
def
_low_level_exec_command
(
self
,
conn
,
cmd
,
tmp
,
sudoable
=
False
,
executable
=
None
,
in_data
=
None
):
def
_low_level_exec_command
(
self
,
conn
,
cmd
,
tmp
,
sudoable
=
False
,
executable
=
None
):
''' execute a command string over SSH, return the output '''
''' execute a command string over SSH, return the output '''
if
executable
is
None
:
if
executable
is
None
:
...
@@ -807,7 +768,7 @@ class Runner(object):
...
@@ -807,7 +768,7 @@ class Runner(object):
if
conn
.
user
==
sudo_user
:
if
conn
.
user
==
sudo_user
:
sudoable
=
False
sudoable
=
False
rc
,
stdin
,
stdout
,
stderr
=
conn
.
exec_command
(
cmd
,
tmp
,
sudo_user
,
sudoable
=
sudoable
,
executable
=
executable
,
in_data
=
in_data
)
rc
,
stdin
,
stdout
,
stderr
=
conn
.
exec_command
(
cmd
,
tmp
,
sudo_user
,
sudoable
=
sudoable
,
executable
=
executable
)
if
type
(
stdout
)
not
in
[
str
,
unicode
]:
if
type
(
stdout
)
not
in
[
str
,
unicode
]:
out
=
''
.
join
(
stdout
.
readlines
())
out
=
''
.
join
(
stdout
.
readlines
())
...
@@ -897,39 +858,27 @@ class Runner(object):
...
@@ -897,39 +858,27 @@ class Runner(object):
raise
errors
.
AnsibleError
(
'failed to resolve remote temporary directory from
%
s: `
%
s` returned empty string'
%
(
basetmp
,
cmd
))
raise
errors
.
AnsibleError
(
'failed to resolve remote temporary directory from
%
s: `
%
s` returned empty string'
%
(
basetmp
,
cmd
))
return
rc
return
rc
# *****************************************************
# *****************************************************
def
_copy_module
(
self
,
conn
,
tmp
,
module_name
,
module_args
,
inject
,
complex_args
=
None
):
def
_copy_module
(
self
,
conn
,
tmp
,
module_name
,
module_args
,
inject
,
complex_args
=
None
):
''' transfer a module over SFTP, does not run it '''
''' transfer a module over SFTP, does not run it '''
(
module_style
,
module_shebang
,
module_data
)
=
self
.
_configure_module
(
conn
,
module_name
,
module_args
,
inject
,
complex_args
)
module_remote_path
=
os
.
path
.
join
(
tmp
,
module_name
)
self
.
_transfer_str
(
conn
,
tmp
,
module_name
,
module_data
)
return
(
module_remote_path
,
module_style
,
module_shebang
)
# *****************************************************
def
_configure_module
(
self
,
conn
,
module_name
,
module_args
,
inject
,
complex_args
=
None
):
''' find module and configure it '''
# Search module path(s) for named module.
# Search module path(s) for named module.
module
_path
=
utils
.
plugins
.
module_finder
.
find_plugin
(
module_name
)
in
_path
=
utils
.
plugins
.
module_finder
.
find_plugin
(
module_name
)
if
module
_path
is
None
:
if
in
_path
is
None
:
raise
errors
.
AnsibleFileNotFound
(
"module
%
s not found in
%
s"
%
(
module_name
,
utils
.
plugins
.
module_finder
.
print_paths
()))
raise
errors
.
AnsibleFileNotFound
(
"module
%
s not found in
%
s"
%
(
module_name
,
utils
.
plugins
.
module_finder
.
print_paths
()))
out_path
=
os
.
path
.
join
(
tmp
,
module_name
)
# insert shared code and arguments into the module
# insert shared code and arguments into the module
(
module_data
,
module_style
,
module_
shebang
)
=
module_replacer
.
modify_module
(
(
module_data
,
module_style
,
shebang
)
=
module_replacer
.
modify_module
(
module
_path
,
complex_args
,
module_args
,
inject
in
_path
,
complex_args
,
module_args
,
inject
)
)
return
(
module_style
,
module_shebang
,
module_data
)
self
.
_transfer_str
(
conn
,
tmp
,
module_name
,
module_data
)
return
(
out_path
,
module_style
,
shebang
)
# *****************************************************
# *****************************************************
...
...
lib/ansible/runner/action_plugins/add_host.py
View file @
74e4ccb5
...
@@ -29,7 +29,7 @@ class ActionModule(object):
...
@@ -29,7 +29,7 @@ class ActionModule(object):
### We need to be able to modify the inventory
### We need to be able to modify the inventory
BYPASS_HOST_LOOP
=
True
BYPASS_HOST_LOOP
=
True
TRANSFERS_FILES
=
False
NEEDS_TMPPATH
=
False
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/assemble.py
View file @
74e4ccb5
...
@@ -26,8 +26,6 @@ from ansible.runner.return_data import ReturnData
...
@@ -26,8 +26,6 @@ from ansible.runner.return_data import ReturnData
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
True
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/copy.py
View file @
74e4ccb5
...
@@ -35,8 +35,6 @@ sys.setdefaultencoding("utf8")
...
@@ -35,8 +35,6 @@ sys.setdefaultencoding("utf8")
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
True
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/debug.py
View file @
74e4ccb5
...
@@ -24,7 +24,7 @@ from ansible.runner.return_data import ReturnData
...
@@ -24,7 +24,7 @@ from ansible.runner.return_data import ReturnData
class
ActionModule
(
object
):
class
ActionModule
(
object
):
''' Print statements during execution '''
''' Print statements during execution '''
TRANSFERS_FILES
=
False
NEEDS_TMPPATH
=
False
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/fail.py
View file @
74e4ccb5
...
@@ -23,7 +23,7 @@ from ansible.runner.return_data import ReturnData
...
@@ -23,7 +23,7 @@ from ansible.runner.return_data import ReturnData
class
ActionModule
(
object
):
class
ActionModule
(
object
):
''' Fail with custom message '''
''' Fail with custom message '''
TRANSFERS_FILES
=
False
NEEDS_TMPPATH
=
False
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/group_by.py
View file @
74e4ccb5
...
@@ -28,7 +28,7 @@ class ActionModule(object):
...
@@ -28,7 +28,7 @@ class ActionModule(object):
### We need to be able to modify the inventory
### We need to be able to modify the inventory
BYPASS_HOST_LOOP
=
True
BYPASS_HOST_LOOP
=
True
TRANSFERS_FILES
=
False
NEEDS_TMPPATH
=
False
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/include_vars.py
View file @
74e4ccb5
...
@@ -23,7 +23,7 @@ from ansible.runner.return_data import ReturnData
...
@@ -23,7 +23,7 @@ from ansible.runner.return_data import ReturnData
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
False
NEEDS_TMPPATH
=
False
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/raw.py
View file @
74e4ccb5
...
@@ -23,7 +23,7 @@ from ansible import errors
...
@@ -23,7 +23,7 @@ from ansible import errors
from
ansible.runner.return_data
import
ReturnData
from
ansible.runner.return_data
import
ReturnData
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
False
NEEDS_TMPPATH
=
False
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/script.py
View file @
74e4ccb5
...
@@ -26,8 +26,6 @@ from ansible.runner.return_data import ReturnData
...
@@ -26,8 +26,6 @@ from ansible.runner.return_data import ReturnData
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
True
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/set_fact.py
View file @
74e4ccb5
...
@@ -20,7 +20,7 @@ from ansible.runner.return_data import ReturnData
...
@@ -20,7 +20,7 @@ from ansible.runner.return_data import ReturnData
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
False
NEEDS_TMPPATH
=
False
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/template.py
View file @
74e4ccb5
...
@@ -25,8 +25,6 @@ import base64
...
@@ -25,8 +25,6 @@ import base64
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
True
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/action_plugins/unarchive.py
View file @
74e4ccb5
...
@@ -35,8 +35,6 @@ import pipes
...
@@ -35,8 +35,6 @@ import pipes
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
True
def
__init__
(
self
,
runner
):
def
__init__
(
self
,
runner
):
self
.
runner
=
runner
self
.
runner
=
runner
...
...
lib/ansible/runner/connection_plugins/accelerate.py
View file @
74e4ccb5
...
@@ -49,7 +49,6 @@ class Connection(object):
...
@@ -49,7 +49,6 @@ class Connection(object):
self
.
port
=
port
[
0
]
self
.
port
=
port
[
0
]
self
.
accport
=
port
[
1
]
self
.
accport
=
port
[
1
]
self
.
is_connected
=
False
self
.
is_connected
=
False
self
.
has_pipelining
=
False
if
not
self
.
port
:
if
not
self
.
port
:
self
.
port
=
constants
.
DEFAULT_REMOTE_PORT
self
.
port
=
constants
.
DEFAULT_REMOTE_PORT
...
@@ -159,12 +158,9 @@ class Connection(object):
...
@@ -159,12 +158,9 @@ class Connection(object):
except
socket
.
timeout
:
except
socket
.
timeout
:
raise
errors
.
AnsibleError
(
"timed out while waiting to receive data"
)
raise
errors
.
AnsibleError
(
"timed out while waiting to receive data"
)
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'
):
''' 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"
)
if
executable
==
""
:
if
executable
==
""
:
executable
=
constants
.
DEFAULT_EXECUTABLE
executable
=
constants
.
DEFAULT_EXECUTABLE
...
...
lib/ansible/runner/connection_plugins/chroot.py
View file @
74e4ccb5
...
@@ -30,7 +30,6 @@ class Connection(object):
...
@@ -30,7 +30,6 @@ class Connection(object):
def
__init__
(
self
,
runner
,
host
,
port
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
runner
,
host
,
port
,
*
args
,
**
kwargs
):
self
.
chroot
=
host
self
.
chroot
=
host
self
.
has_pipelining
=
False
if
os
.
geteuid
()
!=
0
:
if
os
.
geteuid
()
!=
0
:
raise
errors
.
AnsibleError
(
"chroot connection requires running as root"
)
raise
errors
.
AnsibleError
(
"chroot connection requires running as root"
)
...
@@ -60,12 +59,9 @@ class Connection(object):
...
@@ -60,12 +59,9 @@ class Connection(object):
return
self
return
self
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'
):
''' run a command on the chroot '''
''' run a command on the chroot '''
if
in_data
:
raise
errors
.
AnsibleError
(
"Internal Error: this module does not support optimized module pipelining"
)
# We enter chroot as root so sudo stuff can be ignored
# We enter chroot as root so sudo stuff can be ignored
if
executable
:
if
executable
:
...
...
lib/ansible/runner/connection_plugins/fireball.py
View file @
74e4ccb5
...
@@ -37,7 +37,6 @@ class Connection(object):
...
@@ -37,7 +37,6 @@ class Connection(object):
def
__init__
(
self
,
runner
,
host
,
port
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
runner
,
host
,
port
,
*
args
,
**
kwargs
):
self
.
runner
=
runner
self
.
runner
=
runner
self
.
has_pipelining
=
False
# attempt to work around shared-memory funness
# attempt to work around shared-memory funness
if
getattr
(
self
.
runner
,
'aes_keys'
,
None
):
if
getattr
(
self
.
runner
,
'aes_keys'
,
None
):
...
@@ -68,12 +67,9 @@ class Connection(object):
...
@@ -68,12 +67,9 @@ class Connection(object):
return
self
return
self
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'
):
''' 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"
)
vvv
(
"EXEC COMMAND
%
s"
%
cmd
)
vvv
(
"EXEC COMMAND
%
s"
%
cmd
)
if
self
.
runner
.
sudo
and
sudoable
:
if
self
.
runner
.
sudo
and
sudoable
:
...
...
lib/ansible/runner/connection_plugins/funcd.py
View file @
74e4ccb5
...
@@ -42,7 +42,6 @@ class Connection(object):
...
@@ -42,7 +42,6 @@ class Connection(object):
def
__init__
(
self
,
runner
,
host
,
port
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
runner
,
host
,
port
,
*
args
,
**
kwargs
):
self
.
runner
=
runner
self
.
runner
=
runner
self
.
host
=
host
self
.
host
=
host
self
.
has_pipelining
=
False
# port is unused, this go on func
# port is unused, this go on func
self
.
port
=
port
self
.
port
=
port
...
@@ -54,12 +53,9 @@ class Connection(object):
...
@@ -54,12 +53,9 @@ class Connection(object):
return
self
return
self
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
,
sudoable
=
False
,
def
exec_command
(
self
,
cmd
,
tmp_path
,
sudo_user
,
sudoable
=
False
,
executable
=
'/bin/sh'
,
in_data
=
None
):
executable
=
'/bin/sh'
):
''' run a command on the remote minion '''
''' run a command on the remote minion '''
if
in_data
:
raise
errors
.
AnsibleError
(
"Internal Error: this module does not support optimized module pipelining"
)
vvv
(
"EXEC
%
s"
%
(
cmd
),
host
=
self
.
host
)
vvv
(
"EXEC
%
s"
%
(
cmd
),
host
=
self
.
host
)
p
=
self
.
client
.
command
.
run
(
cmd
)[
self
.
host
]
p
=
self
.
client
.
command
.
run
(
cmd
)[
self
.
host
]
return
(
p
[
0
],
''
,
p
[
1
],
p
[
2
])
return
(
p
[
0
],
''
,
p
[
1
],
p
[
2
])
...
...
lib/ansible/runner/connection_plugins/jail.py
View file @
74e4ccb5
...
@@ -60,7 +60,6 @@ class Connection(object):
...
@@ -60,7 +60,6 @@ class Connection(object):
self
.
jail
=
host
self
.
jail
=
host
self
.
runner
=
runner
self
.
runner
=
runner
self
.
host
=
host
self
.
host
=
host
self
.
has_pipelining
=
False
if
os
.
geteuid
()
!=
0
:
if
os
.
geteuid
()
!=
0
:
raise
errors
.
AnsibleError
(
"jail connection requires running as root"
)
raise
errors
.
AnsibleError
(
"jail connection requires running as root"
)
...
@@ -91,12 +90,9 @@ class Connection(object):
...
@@ -91,12 +90,9 @@ class Connection(object):
local_cmd
=
'
%
s "
%
s"
%
s'
%
(
self
.
jexec_cmd
,
self
.
jail
,
cmd
)
local_cmd
=
'
%
s "
%
s"
%
s'
%
(
self
.
jexec_cmd
,
self
.
jail
,
cmd
)
return
local_cmd
return
local_cmd
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'
):
''' run a command on the chroot '''
''' run a command on the chroot '''
if
in_data
:
raise
errors
.
AnsibleError
(
"Internal Error: this module does not support optimized module pipelining"
)
# We enter chroot as root so sudo stuff can be ignored
# We enter chroot as root so sudo stuff can be ignored
local_cmd
=
self
.
_generate_cmd
(
executable
,
cmd
)
local_cmd
=
self
.
_generate_cmd
(
executable
,
cmd
)
...
...
lib/ansible/runner/connection_plugins/local.py
View file @
74e4ccb5
...
@@ -34,19 +34,15 @@ class Connection(object):
...
@@ -34,19 +34,15 @@ class Connection(object):
self
.
host
=
host
self
.
host
=
host
# port is unused, since this is local
# port is unused, since this is local
self
.
port
=
port
self
.
port
=
port
self
.
has_pipelining
=
False
def
connect
(
self
,
port
=
None
):
def
connect
(
self
,
port
=
None
):
''' connect to the local host; nothing to do here '''
''' connect to the local host; nothing to do here '''
return
self
return
self
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'
):
''' run a command on the local host '''
''' run a command on the local host '''
if
in_data
:
raise
errors
.
AnsibleError
(
"Internal Error: this module does not support optimized module pipelining"
)
if
not
self
.
runner
.
sudo
or
not
sudoable
:
if
not
self
.
runner
.
sudo
or
not
sudoable
:
if
executable
:
if
executable
:
local_cmd
=
[
executable
,
'-c'
,
cmd
]
local_cmd
=
[
executable
,
'-c'
,
cmd
]
...
...
lib/ansible/runner/connection_plugins/paramiko_ssh.py
View file @
74e4ccb5
...
@@ -121,7 +121,6 @@ class Connection(object):
...
@@ -121,7 +121,6 @@ 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
=
False
def
_cache_key
(
self
):
def
_cache_key
(
self
):
return
"
%
s__
%
s__"
%
(
self
.
host
,
self
.
user
)
return
"
%
s__
%
s__"
%
(
self
.
host
,
self
.
user
)
...
@@ -176,12 +175,9 @@ class Connection(object):
...
@@ -176,12 +175,9 @@ class Connection(object):
return
ssh
return
ssh
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'
):
''' 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
()
...
...
lib/ansible/runner/connection_plugins/ssh.py
View file @
74e4ccb5
...
@@ -45,7 +45,6 @@ class Connection(object):
...
@@ -45,7 +45,6 @@ class Connection(object):
self
.
password
=
password
self
.
password
=
password
self
.
private_key_file
=
private_key_file
self
.
private_key_file
=
private_key_file
self
.
HASHED_KEY_MAGIC
=
"|1|"
self
.
HASHED_KEY_MAGIC
=
"|1|"
self
.
has_pipelining
=
False
fcntl
.
lockf
(
self
.
runner
.
process_lockfile
,
fcntl
.
LOCK_EX
)
fcntl
.
lockf
(
self
.
runner
.
process_lockfile
,
fcntl
.
LOCK_EX
)
self
.
cp_dir
=
utils
.
prepare_writeable_dir
(
'$HOME/.ansible/cp'
,
mode
=
0700
)
self
.
cp_dir
=
utils
.
prepare_writeable_dir
(
'$HOME/.ansible/cp'
,
mode
=
0700
)
...
@@ -145,12 +144,9 @@ class Connection(object):
...
@@ -145,12 +144,9 @@ class Connection(object):
return
False
return
False
return
True
return
True
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'
):
''' 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"
)
ssh_cmd
=
self
.
_password_cmd
()
ssh_cmd
=
self
.
_password_cmd
()
ssh_cmd
+=
[
"ssh"
,
"-tt"
]
ssh_cmd
+=
[
"ssh"
,
"-tt"
]
if
utils
.
VERBOSITY
>
3
:
if
utils
.
VERBOSITY
>
3
:
...
...
lib/ansible/runner/connection_plugins/ssh_alt.py
View file @
74e4ccb5
...
@@ -45,7 +45,6 @@ class Connection(object):
...
@@ -45,7 +45,6 @@ class Connection(object):
self
.
password
=
password
self
.
password
=
password
self
.
private_key_file
=
private_key_file
self
.
private_key_file
=
private_key_file
self
.
HASHED_KEY_MAGIC
=
"|1|"
self
.
HASHED_KEY_MAGIC
=
"|1|"
self
.
has_pipelining
=
True
fcntl
.
lockf
(
self
.
runner
.
process_lockfile
,
fcntl
.
LOCK_EX
)
fcntl
.
lockf
(
self
.
runner
.
process_lockfile
,
fcntl
.
LOCK_EX
)
self
.
cp_dir
=
utils
.
prepare_writeable_dir
(
'$HOME/.ansible/cp'
,
mode
=
0700
)
self
.
cp_dir
=
utils
.
prepare_writeable_dir
(
'$HOME/.ansible/cp'
,
mode
=
0700
)
...
@@ -145,13 +144,11 @@ class Connection(object):
...
@@ -145,13 +144,11 @@ class Connection(object):
return
False
return
False
return
True
return
True
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'
):
''' run a command on the remote host '''
''' run a command on the remote host '''
ssh_cmd
=
self
.
_password_cmd
()
ssh_cmd
=
self
.
_password_cmd
()
ssh_cmd
+=
[
"ssh"
,
"-C"
]
ssh_cmd
+=
[
"ssh"
,
"-tt"
]
if
not
in_data
:
ssh_cmd
+=
[
"-tt"
]
if
utils
.
VERBOSITY
>
3
:
if
utils
.
VERBOSITY
>
3
:
ssh_cmd
+=
[
"-vvv"
]
ssh_cmd
+=
[
"-vvv"
]
else
:
else
:
...
@@ -181,26 +178,19 @@ class Connection(object):
...
@@ -181,26 +178,19 @@ class Connection(object):
fcntl
.
lockf
(
self
.
runner
.
process_lockfile
,
fcntl
.
LOCK_EX
)
fcntl
.
lockf
(
self
.
runner
.
process_lockfile
,
fcntl
.
LOCK_EX
)
fcntl
.
lockf
(
self
.
runner
.
output_lockfile
,
fcntl
.
LOCK_EX
)
fcntl
.
lockf
(
self
.
runner
.
output_lockfile
,
fcntl
.
LOCK_EX
)
# create process
if
in_data
:
# do not use pseudo-pty
try
:
# Make sure stdin is a proper (pseudo) pty to avoid: tcgetattr errors
master
,
slave
=
pty
.
openpty
()
p
=
subprocess
.
Popen
(
ssh_cmd
,
stdin
=
slave
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdin
=
os
.
fdopen
(
master
,
'w'
,
0
)
os
.
close
(
slave
)
except
:
p
=
subprocess
.
Popen
(
ssh_cmd
,
stdin
=
subprocess
.
PIPE
,
p
=
subprocess
.
Popen
(
ssh_cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdin
=
p
.
stdin
stdin
=
p
.
stdin
else
:
# try to use upseudo-pty
try
:
# Make sure stdin is a proper (pseudo) pty to avoid: tcgetattr errors
master
,
slave
=
pty
.
openpty
()
p
=
subprocess
.
Popen
(
ssh_cmd
,
stdin
=
slave
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdin
=
os
.
fdopen
(
master
,
'w'
,
0
)
os
.
close
(
slave
)
except
:
p
=
subprocess
.
Popen
(
ssh_cmd
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdin
=
p
.
stdin
self
.
_send_password
()
self
.
_send_password
()
...
@@ -208,9 +198,6 @@ class Connection(object):
...
@@ -208,9 +198,6 @@ class Connection(object):
fcntl
.
fcntl
(
p
.
stdout
,
fcntl
.
F_SETFL
,
fcntl
.
fcntl
(
p
.
stdout
,
fcntl
.
F_SETFL
,
fcntl
.
fcntl
(
p
.
stdout
,
fcntl
.
F_GETFL
)
|
os
.
O_NONBLOCK
)
fcntl
.
fcntl
(
p
.
stdout
,
fcntl
.
F_GETFL
)
|
os
.
O_NONBLOCK
)
sudo_output
=
''
sudo_output
=
''
if
in_data
:
# no terminal => no prompt on output. process is waiting for sudo_pass
stdin
.
write
(
self
.
runner
.
sudo_pass
+
'
\n
'
)
while
not
sudo_output
.
endswith
(
prompt
)
and
success_key
not
in
sudo_output
:
while
not
sudo_output
.
endswith
(
prompt
)
and
success_key
not
in
sudo_output
:
rfd
,
wfd
,
efd
=
select
.
select
([
p
.
stdout
],
[],
rfd
,
wfd
,
efd
=
select
.
select
([
p
.
stdout
],
[],
[
p
.
stdout
],
self
.
runner
.
timeout
)
[
p
.
stdout
],
self
.
runner
.
timeout
)
...
@@ -225,16 +212,11 @@ class Connection(object):
...
@@ -225,16 +212,11 @@ class Connection(object):
if
success_key
not
in
sudo_output
:
if
success_key
not
in
sudo_output
:
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
)
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
# We can't use p.communicate here because the ControlMaster may have stdout open as well
stdout
=
''
stdout
=
''
stderr
=
''
stderr
=
''
rpipes
=
[
p
.
stdout
,
p
.
stderr
]
rpipes
=
[
p
.
stdout
,
p
.
stderr
]
if
in_data
:
try
:
stdin
.
write
(
in_data
)
stdin
.
close
()
except
:
raise
errors
.
AnsibleError
(
'SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh'
)
while
True
:
while
True
:
rfd
,
wfd
,
efd
=
select
.
select
(
rpipes
,
[],
rpipes
,
1
)
rfd
,
wfd
,
efd
=
select
.
select
(
rpipes
,
[],
rpipes
,
1
)
...
...
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