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
e6c97050
Commit
e6c97050
authored
Feb 11, 2014
by
Richard C Isaacson
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'pib/unarchive_remote' into pull_5136
parents
36250c6b
58acd8cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
11 deletions
+27
-11
lib/ansible/runner/action_plugins/unarchive.py
+16
-10
library/files/unarchive
+11
-1
No files found.
lib/ansible/runner/action_plugins/unarchive.py
View file @
e6c97050
...
...
@@ -50,30 +50,36 @@ class ActionModule(object):
options
.
update
(
utils
.
parse_kv
(
module_args
))
source
=
options
.
get
(
'src'
,
None
)
dest
=
options
.
get
(
'dest'
,
None
)
copy
=
utils
.
boolean
(
options
.
get
(
'copy'
,
'yes'
))
if
source
is
None
or
dest
is
None
:
result
=
dict
(
failed
=
True
,
msg
=
"src (or content) and dest are required"
)
return
ReturnData
(
conn
=
conn
,
result
=
result
)
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
)
if
copy
:
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
)
remote_md5
=
self
.
runner
.
_remote_md5
(
conn
,
tmp
,
dest
)
if
remote_md5
!=
'3'
:
result
=
dict
(
failed
=
True
,
msg
=
"dest must be an existing dir"
)
return
ReturnData
(
conn
=
conn
,
result
=
result
)
# transfer the file to a remote tmp location
tmp_src
=
tmp
+
'source'
conn
.
put_file
(
source
,
tmp_src
)
if
copy
:
# transfer the file to a remote tmp location
tmp_src
=
tmp
+
'source'
conn
.
put_file
(
source
,
tmp_src
)
# handle diff mode client side
# handle check mode client side
# fix file permissions when the copy is done as a different user
if
self
.
runner
.
sudo
and
self
.
runner
.
sudo_user
!=
'root'
:
self
.
runner
.
_low_level_exec_command
(
conn
,
"chmod a+r
%
s"
%
tmp_src
,
tmp
)
module_args
=
"
%
s src=
%
s original_basename=
%
s"
%
(
module_args
,
pipes
.
quote
(
tmp_src
),
pipes
.
quote
(
os
.
path
.
basename
(
source
)))
if
copy
:
if
self
.
runner
.
sudo
and
self
.
runner
.
sudo_user
!=
'root'
:
self
.
runner
.
_low_level_exec_command
(
conn
,
"chmod a+r
%
s"
%
tmp_src
,
tmp
)
module_args
=
"
%
s src=
%
s original_basename=
%
s"
%
(
module_args
,
pipes
.
quote
(
tmp_src
),
pipes
.
quote
(
os
.
path
.
basename
(
source
)))
else
:
module_args
=
"
%
s original_basename=
%
s"
%
(
module_args
,
pipes
.
quote
(
os
.
path
.
basename
(
source
)))
return
self
.
runner
.
_execute_module
(
conn
,
tmp
,
'unarchive'
,
module_args
,
inject
=
inject
,
complex_args
=
complex_args
)
library/files/unarchive
View file @
e6c97050
...
...
@@ -37,6 +37,12 @@ options:
- Remote absolute path where the archive should be unpacked
required: true
default: null
copy:
description:
- Should the file be copied from the local to the remote machine?
required: false
choices: [ "yes", "no" ]
default: "yes"
author: Dylan Martin
todo:
- detect changed/unchanged for .zip files
...
...
@@ -153,6 +159,7 @@ def main():
src
=
dict
(
required
=
True
),
original_basename
=
dict
(
required
=
False
),
# used to handle 'dest is a directory' via template, a slight hack
dest
=
dict
(
required
=
True
),
copy
=
dict
(
default
=
True
,
type
=
'bool'
),
),
add_file_common_args
=
True
,
)
...
...
@@ -162,7 +169,10 @@ def main():
# did tar file arrive?
if
not
os
.
path
.
exists
(
src
):
module
.
fail_json
(
msg
=
"Source '
%
s' failed to transfer"
%
(
src
))
if
copy
:
module
.
fail_json
(
msg
=
"Source '
%
s' failed to transfer"
%
(
src
))
else
:
module
.
fail_json
(
msg
=
"Source '
%
s' does not exist"
%
(
src
))
if
not
os
.
access
(
src
,
os
.
R_OK
):
module
.
fail_json
(
msg
=
"Source '
%
s' not readable"
%
(
src
))
...
...
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