mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-03 23:09:09 -07:00
archive: Fix paramater types (#1039)
* archive: Fix ignored sanity test parameter-list-no-elements * Fix wrong argument type * Add changelog * Add integration test for a list of files
This commit is contained in:
parent
28ac4b79e2
commit
31443e57b1
6 changed files with 32 additions and 17 deletions
|
@ -23,6 +23,7 @@ options:
|
|||
description:
|
||||
- Remote absolute path, glob, or list of paths or globs for the file or files to compress or archive.
|
||||
type: list
|
||||
elements: path
|
||||
required: true
|
||||
format:
|
||||
description:
|
||||
|
@ -40,6 +41,7 @@ options:
|
|||
description:
|
||||
- Remote absolute path, glob, or list of paths or globs for the file or files to exclude from I(path) list and glob expansion.
|
||||
type: list
|
||||
elements: path
|
||||
force_archive:
|
||||
description:
|
||||
- Allow you to force the module to treat this as an archive even if only a single file is specified.
|
||||
|
@ -187,10 +189,10 @@ else:
|
|||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
path=dict(type='list', required=True),
|
||||
path=dict(type='list', elements='path', required=True),
|
||||
format=dict(type='str', default='gz', choices=['bz2', 'gz', 'tar', 'xz', 'zip']),
|
||||
dest=dict(type='path'),
|
||||
exclude_path=dict(type='list'),
|
||||
exclude_path=dict(type='list', elements='path'),
|
||||
force_archive=dict(type='bool', default=False),
|
||||
remove=dict(type='bool', default=False),
|
||||
),
|
||||
|
@ -226,11 +228,7 @@ def main():
|
|||
module.fail_json(msg="lzma or backports.lzma is required when using xz format.")
|
||||
|
||||
for path in paths:
|
||||
b_path = os.path.expanduser(
|
||||
os.path.expandvars(
|
||||
to_bytes(path, errors='surrogate_or_strict')
|
||||
)
|
||||
)
|
||||
b_path = to_bytes(path, errors='surrogate_or_strict')
|
||||
|
||||
# Expand any glob characters. If found, add the expanded glob to the
|
||||
# list of expanded_paths, which might be empty.
|
||||
|
@ -246,11 +244,7 @@ def main():
|
|||
# Only attempt to expand the exclude paths if it exists
|
||||
if exclude_paths:
|
||||
for exclude_path in exclude_paths:
|
||||
b_exclude_path = os.path.expanduser(
|
||||
os.path.expandvars(
|
||||
to_bytes(exclude_path, errors='surrogate_or_strict')
|
||||
)
|
||||
)
|
||||
b_exclude_path = to_bytes(exclude_path, errors='surrogate_or_strict')
|
||||
|
||||
# Expand any glob characters. If found, add the expanded glob to the
|
||||
# list of expanded_paths, which might be empty.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue