Deleting multiple files-ansible file module. - name: Ansible file module to delete multiple files file: path: " { { item }}" state: absent with_items: - devops1.txt - devops2.txt - devops3.txt. To create multiple files and to delete multiple files the code will be the same but small change in …
Alternatively, remove files, symlinks or directories. Many other modules support the same options as the file module - including ansible.builtin.copy, ...
28.08.2019 · Ansible: How to Delete/ReCreate a File while running Ansible Playbook? Last Updated on August 28th, 2019 by App Shah Leave a comment Ansible no doubt the best Infrastructure Automation tool out there which is used by top fortune 500 companies world wide.
13.07.2017 · Deleting multiple files. You can delete multiple files by iterating with Ansible loop. You need to specify all the files to be removed under with_items.The following example will delete all the files given under with_items. The following example will delete the three files given under with_items. Note 1: Make sure the with_items is on the level ...
04.07.2016 · And create a playbook: - hosts: all tasks: - name: Ansible remove files shell: " { { find }} { { COGNOS_HOME }} -xdev -mindepth 1 -delete". This will delete all files and directories in the COGNOS_HOME variable directory/filesystem. The "-mindepth 1" option makes sure that the current directory will not be touched.