在ansible中对json输出排序或接收最新文件

在ansible中对json输出排序或接收最新文件,ansible,Ansible,我想从目录中获取最新的文件,但问题是响应没有排序,所以我的“最新”文件是旧文件,因为使用了json_查询 在我的目录中,我有几个文件 test123.zip => created 01.01.2020 test1234.zip => created 07.01.2020 tested12345.zip => created 04.02.2020 ansible的输出是 test1234.zip test12345.zip test123.zip 因此,test123.zi

我想从目录中获取最新的文件,但问题是响应没有排序,所以我的“最新”文件是旧文件,因为使用了json_查询

在我的目录中,我有几个文件

test123.zip => created 01.01.2020
test1234.zip => created 07.01.2020
tested12345.zip => created 04.02.2020
ansible的输出是

test1234.zip
test12345.zip
test123.zip 
因此,
test123.zip
是最后一个。我不能使用特定的名称,因为名称不同。我需要按日期获取最新的文件

在我的剧本中,我有:

tasks:
      - name: Find the newest zip file
        win_find:
          paths: \\localhost\zipfiles\
          get_checksum: no
        register: zipfile_the_newest
      - debug:
          msg: "{{ zipfile_the_newest | json_query('files[].filename') | last }}"
输出为:

test123.zip

我的问题是如何按日期获取最新文件,或者如何对最新文件将位于底部的输出进行排序。

win\u find:模块返回
creationtime
作为每个文件的属性,因此您需要按该值排序