ansible/test/integration/targets/unarchive/tasks/test_exclude.yml
Philip Douglass ac5f3f8bef
unarchive - Check 'fut_gid' against 'run_gid' in addition to supplemental groups (#65666)
Add integration tests for unarchiving as unprivileged user
Break tasks into separate files for easier reading and maintenance

Create a user by specifying a default group of 'staff' for macOS.

The user module does not actually remove the user directory on macOS,
so explicitly remove it.

Put the removal tasks in an always block to ensure they always run

Co-authored-by: Philip Douglass <philip.douglass@amadeus.com>
Co-authored-by: Sam Doran <sdoran@redhat.com>
2020-07-30 15:28:05 -04:00

48 lines
1.2 KiB
YAML

- name: "Create {{ remote_tmp_dir }}/exclude directory"
file:
state: directory
path: "{{ remote_tmp_dir }}/exclude-{{item}}"
with_items:
- zip
- tar
- name: Unpack archive file excluding regular and glob files.
unarchive:
src: "{{ remote_tmp_dir }}/unarchive-00.{{item}}"
dest: "{{ remote_tmp_dir }}/exclude-{{item}}"
remote_src: yes
exclude:
- "exclude/exclude-*.txt"
- "other/exclude-1.ext"
with_items:
- zip
- tar
- name: verify that the file was unarchived
shell: find {{ remote_tmp_dir }}/exclude-{{item}} chdir={{ remote_tmp_dir }}
register: unarchive00
with_items:
- zip
- tar
- name: verify that archive extraction excluded the files
assert:
that:
- "'exclude/exclude-1.txt' not in item.stdout"
- "'other/exclude-1.ext' not in item.stdout"
with_items:
- "{{ unarchive00.results }}"
- name: remove our zip unarchive destination
file:
path: '{{remote_tmp_dir}}/test-unarchive-zip'
state: absent
- name: remove our test files for the archive
file:
path: '{{remote_tmp_dir}}/{{item}}'
state: absent
with_items:
- foo-unarchive.txt
- foo-unarchive-777.txt
- FOO-UNAR.TXT