ansible/test/integration/targets/unarchive/tasks/test_symlink.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

64 lines
1.8 KiB
YAML

- name: Create a destination dir
file:
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
state: directory
- name: Create a symlink to the detination dir
file:
path: "{{ remote_tmp_dir }}/link-to-unarchive-dir"
src: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
state: "link"
- name: test that unarchive works when dest is a symlink to a dir
unarchive:
src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz"
dest: "{{ remote_tmp_dir }}/link-to-unarchive-dir"
mode: "u+rwX,go+rX"
remote_src: yes
register: unarchive_11
- name: Check that file is really there
stat:
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz/foo-unarchive.txt"
register: unarchive11_stat0
- name: Assert that unarchive when dest is a symlink to a dir worked
assert:
that:
- "unarchive_11.changed == true"
- "unarchive11_stat0.stat.exists == true"
- name: remove our tar.gz unarchive destination
file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent
- name: Create a file
file:
path: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
state: touch
- name: Create a symlink to the file
file:
src: "{{ remote_tmp_dir }}/test-unarchive-tar-gz"
path: "{{ remote_tmp_dir }}/link-to-unarchive-file"
state: "link"
- name: test that unarchive fails when dest is a link to a file
unarchive:
src: "{{ remote_tmp_dir }}/test-unarchive.tar.gz"
dest: "{{ remote_tmp_dir }}/link-to-unarchive-file"
mode: "u+rwX,go+rX"
remote_src: yes
ignore_errors: True
register: unarchive_12
- name: Assert that unarchive when dest is a file failed
assert:
that:
- "unarchive_12.failed == true"
- name: remove our tar.gz unarchive destination
file:
path: '{{ remote_tmp_dir }}/test-unarchive-tar-gz'
state: absent