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
8be8dbc9
Commit
8be8dbc9
authored
Feb 24, 2014
by
Richard C Isaacson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatting cleanup.
parent
087f7c23
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
27 deletions
+29
-27
lib/ansible/runner/action_plugins/script.py
+29
-27
No files found.
lib/ansible/runner/action_plugins/script.py
View file @
8be8dbc9
...
...
@@ -25,8 +25,8 @@ from ansible import utils
from
ansible
import
errors
from
ansible.runner.return_data
import
ReturnData
class
ActionModule
(
object
):
class
ActionModule
(
object
):
TRANSFERS_FILES
=
True
def
__init__
(
self
,
runner
):
...
...
@@ -37,7 +37,8 @@ class ActionModule(object):
if
self
.
runner
.
noop_on_check
(
inject
):
# in check mode, always skip this module
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
dict
(
skipped
=
True
,
msg
=
'check mode not supported for this module'
))
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
dict
(
skipped
=
True
,
msg
=
'check mode not supported for this module'
))
# extract ansible reserved parameters
# From library/command keep in sync
...
...
@@ -52,68 +53,69 @@ class ActionModule(object):
removes
=
v
module_args
=
r
.
sub
(
""
,
module_args
)
if
creates
:
# do not run the command if the line contains creates=filename
# and the filename already exists. This allows idempotence
# of command executions.
module_args_tmp
=
"path=
%
s"
%
creates
module_return
=
self
.
runner
.
_execute_module
(
conn
,
tmp
,
'stat'
,
module_args_tmp
,
inject
=
inject
,
complex_args
=
complex_args
,
persist_files
=
True
)
module_return
=
self
.
runner
.
_execute_module
(
conn
,
tmp
,
'stat'
,
module_args_tmp
,
inject
=
inject
,
complex_args
=
complex_args
,
persist_files
=
True
)
stat
=
module_return
.
result
.
get
(
'stat'
,
None
)
if
stat
and
stat
.
get
(
'exists'
,
False
):
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
dict
(
skipped
=
True
,
msg
=
(
"skipped, since
%
s exists"
%
creates
)
)
)
conn
=
conn
,
comm_ok
=
True
,
result
=
dict
(
skipped
=
True
,
msg
=
(
"skipped, since
%
s exists"
%
creates
)
)
)
if
removes
:
# do not run the command if the line contains removes=filename
# and the filename does not exist. This allows idempotence
# of command executions.
module_args_tmp
=
"path=
%
s"
%
removes
module_return
=
self
.
runner
.
_execute_module
(
conn
,
tmp
,
'stat'
,
module_args_tmp
,
inject
=
inject
,
complex_args
=
complex_args
,
persist_files
=
True
)
module_return
=
self
.
runner
.
_execute_module
(
conn
,
tmp
,
'stat'
,
module_args_tmp
,
inject
=
inject
,
complex_args
=
complex_args
,
persist_files
=
True
)
stat
=
module_return
.
result
.
get
(
'stat'
,
None
)
if
stat
and
not
stat
.
get
(
'exists'
,
False
):
return
ReturnData
(
conn
=
conn
,
comm_ok
=
True
,
result
=
dict
(
skipped
=
True
,
msg
=
(
"skipped, since
%
s does not exist"
%
removes
)
)
)
conn
=
conn
,
comm_ok
=
True
,
result
=
dict
(
skipped
=
True
,
msg
=
(
"skipped, since
%
s does not exist"
%
removes
)
)
)
# Decode the result of shlex.split() to UTF8 to get around a bug in that's been fixed in Python 2.7 but not Python 2.6.
# See: http://bugs.python.org/issue6988
tokens
=
shlex
.
split
(
module_args
.
encode
(
'utf8'
))
tokens
=
shlex
.
split
(
module_args
.
encode
(
'utf8'
))
tokens
=
[
s
.
decode
(
'utf8'
)
for
s
in
tokens
]
# extract source script
source
=
tokens
[
0
]
source
=
tokens
[
0
]
# FIXME: error handling
args
=
" "
.
join
(
tokens
[
1
:])
source
=
template
.
template
(
self
.
runner
.
basedir
,
source
,
inject
)
args
=
" "
.
join
(
tokens
[
1
:])
source
=
template
.
template
(
self
.
runner
.
basedir
,
source
,
inject
)
if
'_original_file'
in
inject
:
source
=
utils
.
path_dwim_relative
(
inject
[
'_original_file'
],
'files'
,
source
,
self
.
runner
.
basedir
)
else
:
source
=
utils
.
path_dwim
(
self
.
runner
.
basedir
,
source
)
# transfer the file to a remote tmp location
source
=
source
.
replace
(
'
\x00
'
,
''
)
# why does this happen here?
args
=
args
.
replace
(
'
\x00
'
,
''
)
# why does this happen here?
source
=
source
.
replace
(
'
\x00
'
,
''
)
# why does this happen here?
args
=
args
.
replace
(
'
\x00
'
,
''
)
# why does this happen here?
tmp_src
=
os
.
path
.
join
(
tmp
,
os
.
path
.
basename
(
source
))
tmp_src
=
tmp_src
.
replace
(
'
\x00
'
,
''
)
conn
.
put_file
(
source
,
tmp_src
)
sudoable
=
True
sudoable
=
True
# set file permissions, more permisive when the copy is done as a different user
if
self
.
runner
.
sudo
and
self
.
runner
.
sudo_user
!=
'root'
:
cmd_args_chmod
=
"chmod a+rx
%
s"
%
tmp_src
sudoable
=
False
sudoable
=
False
else
:
cmd_args_chmod
=
"chmod +rx
%
s"
%
tmp_src
self
.
runner
.
_low_level_exec_command
(
conn
,
cmd_args_chmod
,
tmp
,
sudoable
=
sudoable
)
...
...
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