在/var/test1目录下有一个目录:
. .. .git .gitignore file1 file2
我想把它复制到其他位置/var/test2并且已经存在内容:
. .. file1
如果我使用Ansible copy :
- copy: # note the trailing `/` at `src: /var/test1/` in order to copy the contents src: /var/test1/ dest: /var/test2
它会replace/var/test2的file1
如何复制目录内容而不replace目标文件?
默认情况下,强制力量覆盖,也许禁用它会帮助你的情况(强制=否)。
你可能想要使用synchronize_module 。 它有delete选项:
删除dest中不存在的文件(传输之后,不在之前)在srcpath中。 这个选项需要recursion=是。
- copy: src: /var/test1 dest: /var/test2 recursive: True delete: False