Fetch the latest file only

Hi,

This is a simple ansible script to create a zip file with date and time.

I want to fetch only the latest zip file to the destination server. How do I fetch only the latest file ?

`

  • hosts: all
    tasks:
  • name: Ansible zip the configuration directory
    archive:
    path: /home/admin/jboss/standalone/configuration
    dest: /home/admin/jboss/standalone/configuration.{{ lookup(‘pipe’, ‘date +%Y%m%d%H%M%S’) }}.zip
    format: zip

`

Regards,
Uday

no help ?

Since the latest file you create is the latest one, store the lookup date in a variable with set_fact then you know the filename to fetch.