You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/integration/targets/copy/tasks/src_file_dest_file_in_non_e...

33 lines
717 B
YAML

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

- name: Ensure that dest top directory doesn't exist
file:
path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
state: absent
- name: create src file
file:
path: foo.txt
state: touch
- name: Copy file, dest is a file in non-existing target directory
copy:
src: foo.txt
dest: '{{ remote_dir }}/{{ dest }}'
remote_src: true
register: copy_result
ignore_errors: True
- name: Assert copy failed
assert:
that:
- 'copy_result is failed'
- name: Stat dest path
stat:
path: '{{ remote_dir }}/{{ dest.split("/")[0] }}'
register: stat_file_in_dir_result
- name: assert that dest doesn't exist
assert:
that:
- 'not stat_file_in_dir_result.stat.exists'