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
d35c9a30
Commit
d35c9a30
authored
Sep 30, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor refactorings
parent
888bcd65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
lib/ansible/plugins/connection/chroot.py
+9
-13
No files found.
lib/ansible/plugins/connection/chroot.py
View file @
d35c9a30
...
...
@@ -36,15 +36,14 @@ BUFSIZE = 65536
class
Connection
(
ConnectionBase
):
''' Local chroot based connections '''
has_pipelining
=
True
transport
=
'chroot'
has_pipelining
=
True
# su currently has an undiagnosed issue with calculating the file
# checksums (so copy, for instance, doesn't work right)
# Have to look into that before re-enabling this
become_methods
=
frozenset
(
C
.
BECOME_METHODS
)
.
difference
((
'su'
,))
def
__init__
(
self
,
play_context
,
new_stdin
,
*
args
,
**
kwargs
):
super
(
Connection
,
self
)
.
__init__
(
play_context
,
new_stdin
,
*
args
,
**
kwargs
)
self
.
chroot
=
self
.
_play_context
.
remote_addr
...
...
@@ -68,15 +67,11 @@ class Connection(ConnectionBase):
def
_connect
(
self
):
''' connect to the chroot; nothing to do here '''
super
(
Connection
,
self
)
.
_connect
()
self
.
_display
.
vvv
(
"THIS IS A LOCAL CHROOT DIR"
,
host
=
self
.
chroot
)
def
_generate_cmd
(
self
,
cmd
,
executable
):
# subprocess takes byte strings
local_cmd
=
[
self
.
chroot_cmd
,
self
.
chroot
,
executable
,
'-c'
]
local_cmd
.
append
(
cmd
)
return
local_cmd
if
not
self
.
_connected
:
self
.
_display
.
vvv
(
"THIS IS A LOCAL CHROOT DIR"
,
host
=
self
.
chroot
)
self
.
_connected
=
True
def
_buffered_exec_command
(
self
,
cmd
,
in_data
=
None
,
sudoable
=
False
,
stdin
=
subprocess
.
PIPE
):
def
_buffered_exec_command
(
self
,
cmd
,
stdin
=
subprocess
.
PIPE
):
''' run a command on the chroot. This is only needed for implementing
put_file() get_file() so that we don't have to read the whole file
into memory.
...
...
@@ -85,7 +80,7 @@ class Connection(ConnectionBase):
return the process's exit code immediately.
'''
executable
=
C
.
DEFAULT_EXECUTABLE
.
split
()[
0
]
if
C
.
DEFAULT_EXECUTABLE
else
'/bin/sh'
local_cmd
=
self
.
_generate_cmd
(
cmd
,
executable
)
local_cmd
=
[
self
.
chroot_cmd
,
self
.
chroot
,
executable
,
'-c'
,
cmd
]
self
.
_display
.
vvv
(
"EXEC
%
s"
%
(
local_cmd
),
host
=
self
.
chroot
)
# FIXME: cwd= needs to be set to the basedir of the playbook, which
...
...
@@ -99,7 +94,7 @@ class Connection(ConnectionBase):
''' run a command on the chroot '''
super
(
Connection
,
self
)
.
exec_command
(
cmd
,
in_data
=
in_data
,
sudoable
=
sudoable
)
p
=
self
.
_buffered_exec_command
(
cmd
,
in_data
,
sudoable
)
p
=
self
.
_buffered_exec_command
(
cmd
)
stdout
,
stderr
=
p
.
communicate
(
in_data
)
return
(
p
.
returncode
,
stdout
,
stderr
)
...
...
@@ -152,4 +147,5 @@ class Connection(ConnectionBase):
def
close
(
self
):
''' terminate the connection; nothing to do here '''
pass
super
(
Connection
,
self
)
.
close
()
self
.
_connected
=
False
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