diff --git a/library/files/copy b/library/files/copy index 08aa1d71a40..862a1ac77b4 100644 --- a/library/files/copy +++ b/library/files/copy @@ -111,7 +111,7 @@ def split_pre_existing_dir(dirname): (pre_existing_dir, new_directory_list) = split_pre_existing_dir(head) else: return (head, [ tail ]) - new_directory_list.insert(0, tail) + new_directory_list.append(tail) return (pre_existing_dir, new_directory_list) diff --git a/test/integration/roles/test_copy/files/subdir/subdir2/subdir3/subdir4/qux.txt b/test/integration/roles/test_copy/files/subdir/subdir2/subdir3/subdir4/qux.txt new file mode 100644 index 00000000000..78df5b06bd3 --- /dev/null +++ b/test/integration/roles/test_copy/files/subdir/subdir2/subdir3/subdir4/qux.txt @@ -0,0 +1 @@ +qux \ No newline at end of file diff --git a/test/integration/roles/test_copy/tasks/main.yml b/test/integration/roles/test_copy/tasks/main.yml index dcbb583a482..28c1f973c9a 100644 --- a/test/integration/roles/test_copy/tasks/main.yml +++ b/test/integration/roles/test_copy/tasks/main.yml @@ -99,7 +99,7 @@ file: name={{output_subdir}} state=directory - name: test recursive copy to directory - copy: src=subdir dest={{output_subdir}} + copy: src=subdir dest={{output_subdir}} directory_mode=0700 register: recursive_copy_result - debug: var=recursive_copy_result @@ -112,11 +112,32 @@ stat: path={{output_dir}}/sub/subdir/subdir2/baz.txt register: stat_bar2 +- name: check that a file in a directory whose parent contains a directory alone was transferred + stat: path={{output_dir}}/sub/subdir/subdir2/subdir3/subdir4/qux.txt + register: stat_bar3 + - name: assert recursive copy things assert: that: - "stat_bar.stat.exists" - "stat_bar2.stat.exists" + - "stat_bar3.stat.exists" + +- name: stat the recursively copied directories + stat: path={{output_dir}}/sub/{{item}} + register: dir_stats + with_items: + - "subdir" + - "subdir/subdir2" + - "subdir/subdir2/subdir3" + - "subdir/subdir2/subdir3/subdir4" + +- name: assert recursive copied directories mode + assert: + that: + - "{{item.stat.mode}} == 0700" + with_items: dir_stats.results + # errors on this aren't presently ignored so this test is commented out. But it would be nice to fix. #