blob: 2d0db4e8a872ee6d842e9e6350c6911e1f047b28 (
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
|
- name: Test temp dir on de escalation
hosts: testhost
become: yes
tasks:
- name: create test user
user:
name: tmptest
state: present
group: '{{ "staff" if ansible_facts.distribution == "MacOSX" else omit }}'
- name: execute test case
become_user: tmptest
block:
- name: Test case from issue 41340
blockinfile:
create: yes
block: |
export foo=bar
marker: "# {mark} Here there be a marker"
dest: /tmp/testing.txt
mode: 0644
always:
- name: clean up file
file: path=/tmp/testing.txt state=absent
- name: clean up test user
user: name=tmptest state=absent
become_user: root
- name: Test tempdir is removed
hosts: testhost
gather_facts: false
vars:
# These tests cannot be run with pipelining as it defeats the purpose of
# ensuring remote_tmp is cleaned up. Pipelining is enabled in the test
# inventory
ansible_pipelining: false
# Ensure that the remote_tmp_dir we create allows the unpriv connection user
# to create the remote_tmp
ansible_become: false
tasks:
- import_role:
name: ../setup_remote_tmp_dir
- vars:
# Isolate the remote_tmp used by these tests
ansible_remote_tmp: "{{ remote_tmp_dir }}/remote_tmp"
block:
- file:
state: touch
path: "{{ remote_tmp_dir }}/65393"
- copy:
src: "{{ remote_tmp_dir }}/65393"
dest: "{{ remote_tmp_dir }}/65393.2"
remote_src: true
- find:
path: "{{ ansible_remote_tmp }}"
use_regex: yes
patterns: 'AnsiballZ_.+\.py'
recurse: true
register: result
- debug:
var: result
- assert:
that:
# Should only be AnsiballZ_find.py because find is actively running
- result.files|length == 1
- result.files[0].path.endswith('/AnsiballZ_find.py')
|