Debian Codegraph @

test/integration/targets/remote_tmp/playbook.yml

raw
1 - name: Test temp dir on de escalation
2 hosts: testhost
3 become: yes
4 tasks:
5 - name: create test user
6 user:
7 name: tmptest
8 state: present
9 group: '{{ "staff" if ansible_facts.distribution == "MacOSX" else omit }}'
10
11 - name: execute test case
12 become_user: tmptest
13 block:
14 - name: Test case from issue 41340
15 blockinfile:
16 create: yes
17 block: |
18 export foo=bar
19 marker: "# {mark} Here there be a marker"
20 dest: /tmp/testing.txt
21 mode: 0644
22 always:
23 - name: clean up file
24 file: path=/tmp/testing.txt state=absent
25
26 - name: clean up test user
27 user: name=tmptest state=absent
28 become_user: root
29
30 - name: Test tempdir is removed
31 hosts: testhost
32 gather_facts: false
33 vars:
34 # These tests cannot be run with pipelining as it defeats the purpose of
35 # ensuring remote_tmp is cleaned up. Pipelining is enabled in the test
36 # inventory
37 ansible_pipelining: false
38 # Ensure that the remote_tmp_dir we create allows the unpriv connection user
39 # to create the remote_tmp
40 ansible_become: false
41 tasks:
42 - import_role:
43 name: ../setup_remote_tmp_dir
44
45 - vars:
46 # Isolate the remote_tmp used by these tests
47 ansible_remote_tmp: "{{ remote_tmp_dir }}/remote_tmp"
48 block:
49 - file:
50 state: touch
51 path: "{{ remote_tmp_dir }}/65393"
52
53 - copy:
54 src: "{{ remote_tmp_dir }}/65393"
55 dest: "{{ remote_tmp_dir }}/65393.2"
56 remote_src: true
57
58 - find:
59 path: "{{ ansible_remote_tmp }}"
60 use_regex: yes
61 patterns: 'AnsiballZ_.+\.py'
62 recurse: true
63 register: result
64
65 - debug:
66 var: result
67
68 - assert:
69 that:
70 # Should only be AnsiballZ_find.py because find is actively running
71 - result.files|length == 1
72 - result.files[0].path.endswith('/AnsiballZ_find.py')