Getting the newest filename in a directory in Ansible
Pure Ansible solution:
- name: Get files in a folder
find:
paths: "/var/www/html/wwwroot/somefolder/"
register: found_files
- name: Get latest file
set_fact:
latest_file: "{{ found_files.files | sort(attribute='mtime',reverse=true) | first }}"