ansible stat check last modified time

4.5k views Asked by At

I have a situation where I need to check the last modified date for a file using ansible. Normally stat in linux has the properties for the file like Modified,access and changed. I know p.stat.isdir and p.stat.pw_name exist but do we have a similar option using ansible stat to check last modified date of a file?

1

There are 1 answers

0
BMW On BEST ANSWER

Ansible has a module with the same name stat.

Its return values contain mtime which is what you are looking for.

mtime
    Time of last modification
    Returned: success, path exists and user can read stats

Source: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html#return-stat/mtime