【发布时间】:2018-06-07 23:04:03
【问题描述】:
我正在尝试运行一个任务,该任务会删除我的项目文件夹的所有内容,而不删除文件夹本身:
我的文件夹 : appFolder ----contains----> file1 , file2 ... fileN , directory1 ...directoryN
我曾尝试使用 ls 、 fileGlob ,但效果不佳。
- name: delete old version files
file:
path: "{{ paths }}"
state: absent
with_filesglob:
- "{{paths}}deletes/*"
还带有 shell 模块(不好,因为它没有删除带有特殊字符名称的文件)
- shell: ls -1 /some/dir
register: contents
- file: path=/some/dir/{{ item }} state=absent
with_items: {{ contents.stdout_lines }}
更好的解决方案?
【问题讨论】:
标签: ansible yaml ansible-2.x