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
c07dd077
Commit
c07dd077
authored
Jul 22, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add raw copy support (raw=yes), tweak tempfile error message string.
parent
2e38d922
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
7 deletions
+31
-7
lib/ansible/runner/__init__.py
+7
-4
lib/ansible/runner/action_plugins/copy.py
+24
-3
No files found.
lib/ansible/runner/__init__.py
View file @
c07dd077
...
...
@@ -728,12 +728,15 @@ class Runner(object):
cmd
+=
' && echo
%
s'
%
basetmp
result
=
self
.
_low_level_exec_command
(
conn
,
cmd
,
None
,
sudoable
=
False
)
# error handling on this seems a little aggressive?
if
result
[
'rc'
]
!=
0
:
raise
errors
.
AnsibleError
(
'could not create temporary directory, SSH exited with result
%
d'
%
result
[
'rc'
])
raise
errors
.
AnsibleError
(
'could not create temporary directory, SSH (
%
s) exited with result
%
d'
%
(
cmd
,
result
[
'rc'
]))
rc
=
utils
.
last_non_blank_line
(
result
[
'stdout'
])
.
strip
()
+
'/'
# Catch
any other failure conditions here;
files should never be
# written
directly to
/.
if
rc
==
'/'
:
# Catch
failure conditions,
files should never be
# written
to locations in
/.
if
rc
.
startswith
(
'/'
)
:
raise
errors
.
AnsibleError
(
'failed to resolve remote temporary directory from
%
s: `
%
s` returned empty string'
%
(
basetmp
,
cmd
))
return
rc
...
...
lib/ansible/runner/action_plugins/copy.py
View file @
c07dd077
...
...
@@ -42,6 +42,7 @@ class ActionModule(object):
source
=
options
.
get
(
'src'
,
None
)
content
=
options
.
get
(
'content'
,
None
)
dest
=
options
.
get
(
'dest'
,
None
)
raw
=
utils
.
boolean
(
options
.
get
(
'raw'
,
'no'
))
force
=
utils
.
boolean
(
options
.
get
(
'force'
,
'yes'
))
if
(
source
is
None
and
content
is
None
and
not
'first_available_file'
in
inject
)
or
dest
is
None
:
...
...
@@ -113,7 +114,7 @@ class ActionModule(object):
exec_rc
=
None
if
local_md5
!=
remote_md5
:
if
self
.
runner
.
diff
:
if
self
.
runner
.
diff
and
not
raw
:
diff
=
self
.
_get_diff_data
(
conn
,
tmp
,
inject
,
dest
,
source
)
else
:
diff
=
{}
...
...
@@ -123,16 +124,29 @@ class ActionModule(object):
os
.
remove
(
tmp_content
)
return
ReturnData
(
conn
=
conn
,
result
=
dict
(
changed
=
True
),
diff
=
diff
)
# transfer the file to a remote tmp location
tmp_src
=
tmp
+
'source'
conn
.
put_file
(
source
,
tmp_src
)
if
not
raw
:
conn
.
put_file
(
source
,
tmp_src
)
else
:
conn
.
put_file
(
source
,
dest
)
if
content
is
not
None
:
os
.
remove
(
tmp_content
)
# fix file permissions when the copy is done as a different user
if
self
.
runner
.
sudo
and
self
.
runner
.
sudo_user
!=
'root'
:
if
self
.
runner
.
sudo
and
self
.
runner
.
sudo_user
!=
'root'
and
not
raw
:
self
.
runner
.
_low_level_exec_command
(
conn
,
"chmod a+r
%
s"
%
tmp_src
,
tmp
)
if
raw
:
return
ReturnData
(
conn
=
conn
,
result
=
dict
(
dest
=
dest
,
changed
=
True
))
# run the copy module
if
'raw'
in
module_args
:
# don't send down raw=no
module_args
.
pop
(
'raw'
)
module_args
=
"
%
s src=
%
s original_basename=
%
s"
%
(
module_args
,
pipes
.
quote
(
tmp_src
),
pipes
.
quote
(
os
.
path
.
basename
(
source
)))
return
self
.
runner
.
_execute_module
(
conn
,
tmp
,
'copy'
,
module_args
,
inject
=
inject
,
complex_args
=
complex_args
)
...
...
@@ -142,7 +156,14 @@ class ActionModule(object):
if
content
is
not
None
:
os
.
remove
(
tmp_content
)
if
raw
:
return
ReturnData
(
conn
=
conn
,
result
=
dict
(
dest
=
dest
,
changed
=
False
))
tmp_src
=
tmp
+
os
.
path
.
basename
(
source
)
if
'raw'
in
module_args
:
# don't send down raw=no
module_args
.
pop
(
'raw'
)
module_args
=
"
%
s src=
%
s"
%
(
module_args
,
pipes
.
quote
(
tmp_src
))
if
self
.
runner
.
check
:
module_args
=
"
%
s CHECKMODE=True"
%
module_args
...
...
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