mirror of https://github.com/ansible/ansible.git
copy: honor directory_mode when specified with remote_src=True (#86184)
* copy: honor directory_mode when specified with remote_src=True * Honor directory_mode specified by user when copying directories and remote_src=True Fixes: #81292 Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>pull/78075/merge
parent
5f2d96c60e
commit
17f3698384
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- copy - honor directory_mode when copying directories with remote_src=True (https://github.com/ansible/ansible/issues/81292).
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
- name: Ensure that dest top directory doesn't exist
|
||||||
|
file:
|
||||||
|
path: '{{ remote_dir }}/{{ item }}'
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- dir1
|
||||||
|
- dir2
|
||||||
|
|
||||||
|
- name: Create directories
|
||||||
|
file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
loop:
|
||||||
|
- dir1
|
||||||
|
- dir2
|
||||||
|
|
||||||
|
- name: Copy file
|
||||||
|
copy:
|
||||||
|
src: 'dir1/'
|
||||||
|
dest: '{{ remote_dir }}/dir2/'
|
||||||
|
remote_src: true
|
||||||
|
mode: "0644"
|
||||||
|
directory_mode: "0755"
|
||||||
|
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 }}/dir2'
|
||||||
|
register: stat_dir2_result
|
||||||
|
|
||||||
|
- name: assert that dir2 exists and has correct mode
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- stat_dir2_result.stat.exists
|
||||||
|
- stat_dir2_result.stat.isdir
|
||||||
|
- stat_dir2_result.stat.mode == "0755"
|
||||||
Loading…
Reference in New Issue