diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /test/integration/targets/unarchive/tasks/test_include.yml | |
parent | Initial commit. (diff) | |
download | ansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/integration/targets/unarchive/tasks/test_include.yml')
-rw-r--r-- | test/integration/targets/unarchive/tasks/test_include.yml | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test/integration/targets/unarchive/tasks/test_include.yml b/test/integration/targets/unarchive/tasks/test_include.yml new file mode 100644 index 0000000..ea3a01c --- /dev/null +++ b/test/integration/targets/unarchive/tasks/test_include.yml @@ -0,0 +1,81 @@ +- name: Create a tar file with multiple files + shell: tar cvf test-unarchive-multi.tar foo-unarchive-777.txt foo-unarchive.txt + args: + chdir: "{{ remote_tmp_dir }}" + +- name: Create include test directories + file: + state: directory + path: "{{ remote_tmp_dir }}/{{ item }}" + loop: + - include-zip + - include-tar + +- name: Unpack zip file include one file + unarchive: + src: "{{ remote_tmp_dir }}/test-unarchive.zip" + dest: "{{ remote_tmp_dir }}/include-zip" + remote_src: yes + include: + - FOO-UNAR.TXT + +- name: Verify that single file was unarchived + find: + paths: "{{ remote_tmp_dir }}/include-zip" + register: unarchive_dir02 + +- name: Verify that zip extraction included only one file + assert: + that: + - file_names == ['FOO-UNAR.TXT'] + vars: + file_names: "{{ unarchive_dir02.files | map(attribute='path') | map('basename') }}" + +- name: Unpack tar file include one file + unarchive: + src: "{{ remote_tmp_dir }}/test-unarchive-multi.tar" + dest: "{{ remote_tmp_dir }}/include-tar" + remote_src: yes + include: + - foo-unarchive-777.txt + +- name: verify that single file was unarchived from tar + find: + paths: "{{ remote_tmp_dir }}/include-tar" + register: unarchive_dir03 + +- name: Verify that tar extraction included only one file + assert: + that: + - file_names == ['foo-unarchive-777.txt'] + vars: + file_names: "{{ unarchive_dir03.files | map(attribute='path') | map('basename') }}" + when: + - "ansible_facts.os_family == 'RedHat'" + - ansible_facts.distribution_major_version is version('7', '>=') + +- name: Check mutually exclusive parameters + unarchive: + src: "{{ remote_tmp_dir }}/test-unarchive-multi.tar" + dest: "{{ remote_tmp_dir }}/include-tar" + remote_src: yes + include: + - foo-unarchive-777.txt + exclude: + - foo + ignore_errors: yes + register: unarchive_mutually_exclusive_check + +- name: Check mutually exclusive parameters + assert: + that: + - unarchive_mutually_exclusive_check is failed + - "'mutually exclusive' in unarchive_mutually_exclusive_check.msg" + +- name: "Remove include feature tests directory" + file: + state: absent + path: "{{ remote_tmp_dir }}/{{ item }}" + loop: + - 'include-zip' + - 'include-tar' |