删除单个文件
- name: Ansible delete file example
file:
path: /etc/delete.conf
state: absent
删除多个文件
[root@localhost uat]# cat deleteJarbackup.yml
- hosts: localhost
tasks:
- name: Ansible Find File Glob
find:
paths: /home/wwwroot/uat.leoyongwei.com/jarBackup
patterns: server-*.jar
register: files_to_find
- name: Ansible Absent File Glob
file:
path: "{{ item.path }}"
state: absent
with_items: "{{ files_to_find.files }}"