Check file for staleness or comparing ctime to current time in Ansible

Hello,

I want to use Ansible for updating Jenkins plugins. So I download the
update information via curl. I do not want to do this every time I run
the playbook but only when the downloaded file is stale, say older
than one day.

I know how to get the stat of the file:
- name: Check Jenkins plugin data is not too old.
  stat:
    path: /var/lib/jenkins/updates/default.json
  register: jenkins_updates_json_stat

Now I want to execute the download and update steps only when
jenkins_updates_json_stat.stat.ctime + 86400 < time.time()

Is there a simple way to get the current time in Ansible?

Regards Mirko

Hi Mirko

Ansible provides the current time in various formats as facts. ansible_date_time.epoch could be what you need?

Regards
Tom

Thanks, Tom, I will give it a try.
Regards Mirko