clicks010
clicks010

Reputation: 67

ansible stat check last modified time

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?

Upvotes: 2

Views: 4922

Answers (1)

BMW
BMW

Reputation: 45223

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

Upvotes: 3

Related Questions