Hello,
I'm writing a playbook for patching and in that i required 2 modules to
Find and Copy the recently modified file in remote machine , I have tried
with below modules, but not working! if someone have an idea, kindly share.
::-Find and copy
- name: find recently modified file and copy it
find: path=/var/tmp/{{ansible_hostname}} patterns="*.tar.xz"
- name: copy files
fetch: path=/var/tmp/{{ansible_hostname}} dest=/kdump/sosreport/
flat=yes
::- Try to find recently modified file.
First play
- name: find recently modified file and copy it
find:
path: "/var/tmp/{{ansible_hostname}}"
register: found_files
- name: Get latest file
set_fact:
latest_file: "{{ found_files.files |
sort(attribute='mtime',age=-1h,reverse=true) | first }}"
Second play
- name: find recently modified file and copy it
find:
path: "/var/tmp/{{ansible_hostname}}"
register: found_files
- name: Get latest file
set_fact:
latest_file: "{{ found_files.files |
sort(attribute='mtime',age=-1h,reverse=true) | first }}"
- name: print matches
debug:
msg: "{{ found_files.files }}"
- name: print matches
debug:
msg: "{{ found_files.files }}"
Thanks,
Deepan M
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/ac637bd4-0eb0-4c64-ac01-43bf2d28f8de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.