mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
* archive: Fix ignored sanity test parameter-list-no-elements
* Fix wrong argument type
* Add changelog
* Add integration test for a list of files
(cherry picked from commit 31443e57b1
)
Co-authored-by: Amin Vakil <info@aminvakil.com>
This commit is contained in:
parent
659ef811a3
commit
02f0abfb36
6 changed files with 32 additions and 17 deletions
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
minor_changes:
|
||||
- archive - fix paramater types (https://github.com/ansible-collections/community.general/pull/1039).
|
|
@ -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.
|
||||
|
|
|
@ -256,6 +256,29 @@
|
|||
- name: remove our xz
|
||||
file: path="{{ output_dir }}/archive_02.xz" state=absent
|
||||
|
||||
- name: archive multiple files as list
|
||||
archive:
|
||||
path:
|
||||
- "{{ output_dir }}/empty.txt"
|
||||
- "{{ output_dir }}/foo.txt"
|
||||
- "{{ output_dir }}/bar.txt"
|
||||
dest: "{{ output_dir }}/archive_list.gz"
|
||||
format: gz
|
||||
register: archive_gz_list_result
|
||||
|
||||
- name: verify that the files archived
|
||||
file: path={{output_dir}}/archive_list.gz state=file
|
||||
|
||||
- name: check if gz file exists and includes all text files
|
||||
assert:
|
||||
that:
|
||||
- "{{ archive_gz_list_result.changed }}"
|
||||
- "{{ 'archived' in archive_gz_list_result }}"
|
||||
- "{{ archive_gz_list_result['archived'] | length }} == 3"
|
||||
|
||||
- name: remove our gz
|
||||
file: path="{{ output_dir }}/archive_list.gz" state=absent
|
||||
|
||||
- name: test that gz archive that contains non-ascii filenames
|
||||
archive:
|
||||
path: "{{ output_dir }}/*.txt"
|
||||
|
|
|
@ -324,8 +324,6 @@ plugins/modules/database/vertica/vertica_schema.py validate-modules:doc-missing-
|
|||
plugins/modules/database/vertica/vertica_schema.py validate-modules:undocumented-parameter
|
||||
plugins/modules/database/vertica/vertica_user.py validate-modules:doc-missing-type
|
||||
plugins/modules/database/vertica/vertica_user.py validate-modules:undocumented-parameter
|
||||
plugins/modules/files/archive.py use-argspec-type-path # fix needed
|
||||
plugins/modules/files/archive.py validate-modules:parameter-list-no-elements
|
||||
plugins/modules/files/iso_extract.py validate-modules:doc-default-does-not-match-spec
|
||||
plugins/modules/files/xml.py validate-modules:doc-required-mismatch
|
||||
plugins/modules/files/xml.py validate-modules:parameter-list-no-elements
|
||||
|
|
|
@ -324,8 +324,6 @@ plugins/modules/database/vertica/vertica_schema.py validate-modules:doc-missing-
|
|||
plugins/modules/database/vertica/vertica_schema.py validate-modules:undocumented-parameter
|
||||
plugins/modules/database/vertica/vertica_user.py validate-modules:doc-missing-type
|
||||
plugins/modules/database/vertica/vertica_user.py validate-modules:undocumented-parameter
|
||||
plugins/modules/files/archive.py use-argspec-type-path # fix needed
|
||||
plugins/modules/files/archive.py validate-modules:parameter-list-no-elements
|
||||
plugins/modules/files/iso_extract.py validate-modules:doc-default-does-not-match-spec
|
||||
plugins/modules/files/xml.py validate-modules:doc-required-mismatch
|
||||
plugins/modules/files/xml.py validate-modules:parameter-list-no-elements
|
||||
|
|
|
@ -292,7 +292,6 @@ plugins/modules/database/vertica/vertica_schema.py validate-modules:doc-missing-
|
|||
plugins/modules/database/vertica/vertica_schema.py validate-modules:undocumented-parameter
|
||||
plugins/modules/database/vertica/vertica_user.py validate-modules:doc-missing-type
|
||||
plugins/modules/database/vertica/vertica_user.py validate-modules:undocumented-parameter
|
||||
plugins/modules/files/archive.py use-argspec-type-path # fix needed
|
||||
plugins/modules/files/iso_extract.py validate-modules:doc-default-does-not-match-spec
|
||||
plugins/modules/identity/keycloak/keycloak_client.py validate-modules:doc-default-does-not-match-spec
|
||||
plugins/modules/identity/keycloak/keycloak_client.py validate-modules:doc-missing-type
|
||||
|
|
Loading…
Reference in a new issue