There is a directory under /var/test1
with content:
.
..
.git
.gitignore
file1
file2
and I want to copy it on an other location /var/test2
with pre-existing content:
.
..
file1
If I use the Ansible copy
:
- copy:
# note the trailing `/` at `src: /var/test1/` in order to copy the contents
src: /var/test1/
dest: /var/test2
it will replace the file1
in the /var/test2
How can I copy the directory contents without replacing the files at the destination?
by default ansible forces overwrites, maybe disabling it would help your case (force=no).
You probably want to use synchronize_module. It has
delete
option: