diff options
author | Ben Doherty <ben@thinkoomph.com> | 2016-05-26 23:42:03 -0400 |
---|---|---|
committer | Ben Doherty <ben@thinkoomph.com> | 2016-05-26 23:42:03 -0400 |
commit | d3e041d1a23c6dfbd8722212e565190382cce4e7 (patch) | |
tree | d1bff1df3a510c0f1a1b2e9332ce819072ff95a1 /files/archive.py | |
parent | cca70b7c9131627681bed77f4fbee5bb6e4823af (diff) | |
download | ansible-modules-extras-d3e041d1a23c6dfbd8722212e565190382cce4e7.tar.gz |
Accept 'path' as a list argument, expose path and expanded_path,
Use correct variable in expanduser
Diffstat (limited to 'files/archive.py')
-rw-r--r-- | files/archive.py | 14 |
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): |