blob: 04842e0ecdb91c7abf949ff78b2a57f305f76ce4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
- 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
# The map filter was added in Jinja2 2.7, which is newer than the version on RHEL/CentOS 6,
# so we skip this validation on those hosts
- 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') }}"
when:
- "ansible_facts.os_family == 'RedHat'"
- ansible_facts.distribution_major_version is version('7', '>=')
- 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'
|