mirror of https://github.com/ansible/ansible.git
copy - fix reporting changed=True when a single-file dir is copied with remote_src=False (#85834)
* Fix directory path construction in the action plugin Fixes #85833pull/85376/merge
parent
9f42cefca6
commit
17fb4af38d
@ -0,0 +1,2 @@
|
||||
bugfixes:
|
||||
- "copy - when a single-file local directory was specified as the source, ``changed`` used to be ``false`` even when the source was actually copied. It now makes sure ``changed`` is ``true`` in this case. (https://github.com/ansible/ansible/issues/85833)"
|
||||
@ -0,0 +1,29 @@
|
||||
# Test copying to a source directory that contains only a single file in a deeper structure
|
||||
|
||||
- name: Ensure that dest top directory doesn't exist
|
||||
file:
|
||||
path: '{{ remote_dir }}/subdir_with_deep_single_file'
|
||||
state: absent
|
||||
|
||||
- name: Copy subdir_with_deep_single_file directory which contains a single file
|
||||
copy:
|
||||
src: subdir_with_deep_single_file
|
||||
dest: '{{ remote_dir }}'
|
||||
register: copy_result
|
||||
|
||||
- name: Debug copy result
|
||||
debug:
|
||||
var: copy_result
|
||||
verbosity: 1
|
||||
|
||||
- name: Check the transferred file
|
||||
stat:
|
||||
path: '{{ remote_dir }}/subdir_with_deep_single_file/dir/file.txt'
|
||||
register: stat_file
|
||||
|
||||
- name: Assert that transferred file exists and copy_result is as expected for deeper structure
|
||||
assert:
|
||||
that:
|
||||
- 'stat_file.stat.exists'
|
||||
- 'copy_result.changed'
|
||||
- 'copy_result.dest == remote_dir + "/subdir_with_deep_single_file/dir/file.txt"'
|
||||
Loading…
Reference in New Issue