mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-09 14:50:02 -07:00
Fix: wildcard excludes in unarchive with tar archives (#40935)
* fix: exclude using wildcards for tar archives Fixes #37842, #22947 * fix: Remove quote() as it munges the exclude format * test: Refactor to use single archive structure A common structure archived by different methods should simplify some of the feature tests. * test: Use common archive layout to validate exclude feature * test: Use the same exclude checks for zip/tar archives
This commit is contained in:
parent
e9b658baae
commit
ba3db90e3a
2 changed files with 67 additions and 19 deletions
|
@ -60,6 +60,39 @@
|
|||
- name: prep a zip file
|
||||
shell: zip test-unarchive.zip foo-unarchive.txt foo-unarchive-777.txt chdir={{output_dir}}
|
||||
|
||||
- name: Prepare - Create test dirs
|
||||
file:
|
||||
path: "{{output_dir}}/{{item}}"
|
||||
state: directory
|
||||
with_items:
|
||||
- created/include
|
||||
- created/exclude
|
||||
- created/other
|
||||
|
||||
- name: Prepare - Create test files
|
||||
file:
|
||||
path: "{{output_dir}}/created/{{item}}"
|
||||
state: touch
|
||||
with_items:
|
||||
- include/include-1.txt
|
||||
- include/include-2.txt
|
||||
- include/include-3.txt
|
||||
- exclude/exclude-1.txt
|
||||
- exclude/exclude-2.txt
|
||||
- exclude/exclude-3.txt
|
||||
- other/include-1.ext
|
||||
- other/include-2.ext
|
||||
- other/exclude-1.ext
|
||||
- other/exclude-2.ext
|
||||
- other/other-1.ext
|
||||
- other/other-2.ext
|
||||
|
||||
- name: Prepare - zip file
|
||||
shell: zip -r {{output_dir}}/unarchive-00.zip * chdir={{output_dir}}/created/
|
||||
|
||||
- name: Prepare - tar file
|
||||
shell: tar czvf {{output_dir}}/unarchive-00.tar * chdir={{output_dir}}/created/
|
||||
|
||||
- name: add a file with Windows permissions to zip file
|
||||
shell: zip -k test-unarchive.zip FOO-UNAR.TXT chdir={{output_dir}}
|
||||
|
||||
|
@ -187,22 +220,33 @@
|
|||
- name: "Create {{ output_dir }}/exclude directory"
|
||||
file:
|
||||
state: directory
|
||||
path: "{{ output_dir }}/exclude"
|
||||
path: "{{ output_dir }}/exclude-{{item}}"
|
||||
with_items:
|
||||
- zip
|
||||
- tar
|
||||
|
||||
- name: Unpack zip file excluding one file.
|
||||
- name: Unpack archive file excluding glob files.
|
||||
unarchive:
|
||||
src: "{{ output_dir }}/test-unarchive.zip"
|
||||
dest: "{{ output_dir }}/exclude"
|
||||
exclude: "foo-unarchive-*.txt"
|
||||
src: "{{ output_dir }}/unarchive-00.{{item}}"
|
||||
dest: "{{ output_dir }}/exclude-{{item}}"
|
||||
exclude: "exclude/exclude-*.txt"
|
||||
with_items:
|
||||
- zip
|
||||
- tar
|
||||
|
||||
- name: verify that the file was unarchived
|
||||
shell: find {{ output_dir }}/exclude chdir={{ output_dir }}
|
||||
register: unarchive_dir01
|
||||
shell: find {{ output_dir }}/exclude-{{item}} chdir={{ output_dir }}
|
||||
register: unarchive00
|
||||
with_items:
|
||||
- zip
|
||||
- tar
|
||||
|
||||
- name: verify that zip extraction excluded file
|
||||
- name: verify that archive extraction excluded the files
|
||||
assert:
|
||||
that:
|
||||
- "'foo-unarchive-777.txt' not in unarchive_dir01.stdout"
|
||||
- "'exclude/exclude-1.txt' not in item.stdout"
|
||||
with_items:
|
||||
- "{{ unarchive00.results }}"
|
||||
|
||||
- name: remove our zip unarchive destination
|
||||
file: path={{output_dir}}/test-unarchive-zip state=absent
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue