Debian Codegraph @

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

raw
1 - name: Test unarchiving twice as unprivileged user
2 vars:
3 ansible_become: yes
4 ansible_become_user: "{{ test_user_name }}"
5 ansible_become_password: "{{ test_user_plaintext_password }}"
6 block:
7 - name: prep our file
8 copy:
9 src: foo.txt
10 dest: "{{ test_user.home }}/foo-unarchive.txt"
11 mode: preserve
12
13 - name: Prep a zip file as {{ test_user.name }} user
14 shell: zip unarchivetest1-unarchive.zip foo-unarchive.txt
15 args:
16 chdir: "{{ test_user.home }}"
17 creates: "{{ test_user.home }}/unarchivetest1-unarchive.zip"
18
19 - name: create our zip unarchive destination as {{ test_user.name }} user
20 file:
21 path: "{{ test_user.home }}/unarchivetest1-unarchive-zip"
22 state: directory
23
24 - name: unarchive a zip file as {{ test_user.name }} user
25 unarchive:
26 src: "{{ test_user.home }}/unarchivetest1-unarchive.zip"
27 dest: "{{ test_user.home }}/unarchivetest1-unarchive-zip"
28 remote_src: yes
29 list_files: True
30 register: unarchive10
31
32 - name: stat the unarchived file
33 stat:
34 path: "{{ test_user.home }}/unarchivetest1-unarchive-zip/foo-unarchive.txt"
35 register: archive_path
36
37 - name: verify that the tasks performed as expected
38 assert:
39 that:
40 - unarchive10 is changed
41 # Verify that file list is generated
42 - "'files' in unarchive10"
43 - unarchive10['files']| length == 1
44 - "'foo-unarchive.txt' in unarchive10['files']"
45 - archive_path.stat.exists
46
47 - name: repeat the last request to verify no changes
48 unarchive:
49 src: "{{ test_user.home }}/unarchivetest1-unarchive.zip"
50 dest: "{{ test_user.home }}/unarchivetest1-unarchive-zip"
51 remote_src: yes
52 list_files: True
53 register: unarchive10b
54
55 # Due to a bug in the date calculation used to determine if a change
56 # was made or not, this check is unreliable. This seems to only happen on
57 # Ubuntu 1604.
58 # https://github.com/ansible/ansible/blob/58145dff9ca1a713f8ed295a0076779a91c41cba/lib/ansible/modules/unarchive.py#L472-L474
59 - name: Check that unarchiving again reports no change
60 assert:
61 that:
62 - unarchive10b is not changed
63 ignore_errors: yes