summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Doherty <ben@thinkoomph.com>2016-05-26 23:42:03 -0400
committerBen Doherty <ben@thinkoomph.com>2016-05-26 23:42:03 -0400
commitd3e041d1a23c6dfbd8722212e565190382cce4e7 (patch)
treed1bff1df3a510c0f1a1b2e9332ce819072ff95a1
parentcca70b7c9131627681bed77f4fbee5bb6e4823af (diff)
downloadansible-modules-extras-d3e041d1a23c6dfbd8722212e565190382cce4e7.tar.gz
Accept 'path' as a list argument, expose path and expanded_path,
Use correct variable in expanduser
-rw-r--r--files/archive.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/files/archive.py b/files/archive.py
index 2dba54a3..87840ec0 100644
--- a/files/archive.py
+++ b/files/archive.py
@@ -110,7 +110,7 @@ import tarfile
def main():
module = AnsibleModule(
argument_spec = dict(
- path = dict(required=True),
+ path = dict(type='list', required=True),
compression = dict(choices=['gz', 'bz2', 'zip'], default='gz', required=False),
creates = dict(required=False),
remove = dict(required=False, default=True, type='bool'),
@@ -133,11 +133,8 @@ def main():
archive = False
successes = []
- if isinstance(paths, basestring):
- paths = [paths]
-
for i, path in enumerate(paths):
- path = os.path.expanduser(params['path'])
+ path = os.path.expanduser(path)
# Detect glob-like characters
if any((c in set('*?')) for c in path):
@@ -146,7 +143,7 @@ def main():
expanded_paths.append(path)
if len(expanded_paths) == 0:
- module.fail_json(path, msg='Error, no source paths were found')
+ module.fail_json(path=', '.join(paths), expanded_paths=', '.join(expanded_paths), msg='Error, no source paths were found')
# If we actually matched multiple files or TRIED to, then
# treat this as a multi-file archive
@@ -170,7 +167,7 @@ def main():
# Use the longest common directory name among all the files
# as the archive root path
if arcroot == '':
- arcroot = os.path.dirname(path)
+ arcroot = os.path.dirname(path) + os.sep
else:
for i in xrange(len(arcroot)):
if path[i] != arcroot[i]:
@@ -259,8 +256,7 @@ def main():
archive.close()
state = 'archive'
-
- if state == 'archive' and remove:
+ if state in ['archive', 'incomplete'] and remove:
for path in successes:
try:
if os.path.isdir(path):