我需要从目录中删除文件,但我想通过ansible保留该文件夹。
我试过使用文件模块,结果发现该目录也被删除了。有什么建议吗?
- name: empty dest directory
file:
state: absent
path: /path/to/directory/
预期:目录:/ path / to / directory为空,但目录存在
实际:目录也被删除
为什么不先将它清空,然后再创建它?
- name: empty dest directory
file:
state: absent
path: /path/to/directory/
- name: recreate directory
file:
state: directory
path: /path/to/directory/