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 now working! please someone have an idea, kindly 
help.

*::-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/a6735e49-f0d3-4c06-b8c2-a184852f2cb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to