2018-07-06 19:49:19 +02:00
|
|
|
- name: Test temp dir on de escalation
|
|
|
|
hosts: testhost
|
|
|
|
become: yes
|
|
|
|
tasks:
|
|
|
|
- name: create test user
|
2020-09-25 21:30:47 +02:00
|
|
|
user:
|
|
|
|
name: tmptest
|
|
|
|
state: present
|
|
|
|
group: '{{ "staff" if ansible_facts.distribution == "MacOSX" else omit }}'
|
2018-07-06 19:49:19 +02:00
|
|
|
|
|
|
|
- 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
|
2019-12-06 23:29:26 +01:00
|
|
|
|
|
|
|
- name: Test tempdir is removed
|
|
|
|
hosts: testhost
|
|
|
|
gather_facts: false
|
|
|
|
tasks:
|
|
|
|
- file:
|
|
|
|
state: touch
|
2020-09-25 21:30:47 +02:00
|
|
|
path: "{{ output_dir }}/65393"
|
2019-12-06 23:29:26 +01:00
|
|
|
|
|
|
|
- copy:
|
2020-09-25 21:30:47 +02:00
|
|
|
src: "{{ output_dir }}/65393"
|
|
|
|
dest: "{{ output_dir }}/65393.2"
|
2019-12-06 23:29:26 +01:00
|
|
|
remote_src: true
|
|
|
|
|
|
|
|
- find:
|
|
|
|
path: "~/.ansible/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')
|