Debian Codegraph @

test/integration/targets/unarchive/tasks/prepare_tests.yml

raw
1 - name: Include system specific variables
2 include_vars: "{{ ansible_facts.system }}.yml"
3
4 # Need unzip for unarchive module, and zip for archive creation.
5 - name: Ensure required binaries are present
6 package:
7 name: "{{ unarchive_packages }}"
8 when: ansible_pkg_mgr in ('dnf', 'apt', 'pkgng')
9
10 - name: prep our file
11 copy:
12 src: foo.txt
13 dest: "{{remote_tmp_dir}}/foo-unarchive.txt"
14 mode: preserve
15
16 - name: prep a tar file
17 shell: tar cvf test-unarchive.tar foo-unarchive.txt chdir={{remote_tmp_dir}}
18
19 - name: prep a tar.gz file
20 shell: tar czvf test-unarchive.tar.gz foo-unarchive.txt chdir={{remote_tmp_dir}}
21
22 - name: see if we have the zstd executable
23 ignore_errors: true
24 shell: zstd --version
25 register: zstd_available
26
27 - when: zstd_available.rc == 0
28 block:
29 - name: find gnu tar
30 shell: |
31 #!/bin/sh
32 which gtar 2>/dev/null
33 if test $? -ne 0; then
34 if test -z "`tar --version | grep bsdtar`"; then
35 which tar
36 fi
37 fi
38 register: gnu_tar
39
40 - name: prep a tar.zst file
41 shell: "{{ gnu_tar.stdout }} --use-compress-program=zstd -cvf test-unarchive.tar.zst foo-unarchive.txt chdir={{remote_tmp_dir}}"
42 when: gnu_tar.stdout != ""
43
44 - name: prep a chmodded file for zip
45 copy:
46 src: foo.txt
47 dest: '{{remote_tmp_dir}}/foo-unarchive-777.txt'
48 mode: '0777'
49
50 - name: prep a windows permission file for our zip
51 copy:
52 src: foo.txt
53 dest: '{{remote_tmp_dir}}/FOO-UNAR.TXT'
54 mode: preserve
55
56 # This gets around an unzip timestamp bug in some distributions
57 # Recent unzip on Ubuntu and BSD will randomly round some timestamps up.
58 # But that doesn't seem to happen when the timestamp has an even second.
59 - name: Bug work around
60 command: touch -t "201705111530.00" {{remote_tmp_dir}}/foo-unarchive.txt {{remote_tmp_dir}}/foo-unarchive-777.txt {{remote_tmp_dir}}/FOO-UNAR.TXT
61 # See Ubuntu bug 1691636: https://bugs.launchpad.net/ubuntu/+source/unzip/+bug/1691636
62 # When these are fixed, this code should be removed.
63
64 - name: prep a zip file
65 shell: zip test-unarchive.zip foo-unarchive.txt foo-unarchive-777.txt chdir={{remote_tmp_dir}}
66
67 - name: Prepare - Create test dirs
68 file:
69 path: "{{remote_tmp_dir}}/{{item}}"
70 state: directory
71 with_items:
72 - created/include
73 - created/exclude
74 - created/other
75
76 - name: Prepare - Create test files
77 file:
78 path: "{{remote_tmp_dir}}/created/{{item}}"
79 state: touch
80 with_items:
81 - include/include-1.txt
82 - include/include-2.txt
83 - include/include-3.txt
84 - exclude/exclude-1.txt
85 - exclude/exclude-2.txt
86 - exclude/exclude-3.txt
87 - other/include-1.ext
88 - other/include-2.ext
89 - other/exclude-1.ext
90 - other/exclude-2.ext
91 - other/other-1.ext
92 - other/other-2.ext
93
94 - name: Prepare - zip file
95 shell: zip -r {{remote_tmp_dir}}/unarchive-00.zip * chdir={{remote_tmp_dir}}/created/
96
97 - name: Prepare - tar file
98 shell: tar czvf {{remote_tmp_dir}}/unarchive-00.tar * chdir={{remote_tmp_dir}}/created/
99
100 - name: add a file with Windows permissions to zip file
101 shell: zip -k test-unarchive.zip FOO-UNAR.TXT chdir={{remote_tmp_dir}}
102
103 - name: prep a subdirectory
104 file:
105 path: '{{remote_tmp_dir}}/unarchive-dir'
106 state: directory
107
108 - name: prep our file
109 copy:
110 src: foo.txt
111 dest: '{{remote_tmp_dir}}/unarchive-dir/foo-unarchive.txt'
112 mode: preserve
113
114 - name: prep a tar.gz file with directory
115 shell: tar czvf test-unarchive-dir.tar.gz unarchive-dir chdir={{remote_tmp_dir}}