delete all files and hidden files in a directory
vars:
app_home: /var/opt/application
tasks:
- name: clear home dir
- shell: "ls -la {{ app_home }}/"
register: files_to_delete
- file: path="{{ app_home }}/{{ item }}" state=absent
with_items: "{{ files_to_delete.stdout_lines }}"
get files from node
ansible node1 -s -m fetch -a "src=/etc/hosts dest=/tmp"
copy file to node
ansible node1 -m copy -a "src=/etc/hosts dest=/tmp/hosts"
remove all files matching a wildcard
file: path={{ item }} state=absent
with_fileglob: /tmp/*.rpm
No comments:
Post a Comment