blob: fad53e71db69ad2ba78cf0a5b28a4ae47f005aca (
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
|
# src is a file, dest is a non-existent directory (2 levels of directories):
# checks that dest is created
- name: Ensure that dest top directory doesn't exist
file:
path: '{{ remote_dir }}/{{ item.dest.split("/")[0] }}'
state: absent
- name: create subdir
file:
path: subdir
state: directory
- name: create src file
file:
path: "{{ item }}"
state: touch
loop:
- foo.txt
- subdir/bar.txt
- name: Copy file, dest is a nonexistent target directory
copy:
src: '{{ item.src }}'
dest: '{{ remote_dir }}/{{ item.dest }}'
remote_src: true
register: copy_result
- name: assert copy worked
assert:
that:
- 'copy_result is successful'
- 'copy_result is changed'
- name: stat copied file
stat:
path: '{{ remote_dir }}/{{ item.check }}'
register: stat_file_in_dir_result
- name: assert that file exists
assert:
that:
- stat_file_in_dir_result.stat.exists
- stat_file_in_dir_result.stat.isreg
|