# File date/time stamps

**URL:** <https://forum.ansible.com/t/file-date-time-stamps/36748>\
**Category:** Ansible Project\
**Created:** [June 17, 2022, 9:56am UTC](https://forum.ansible.com/t/file-date-time-stamps/36748 "2022-06-17T09:56:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antony\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Antony\_Stone](https://forum.ansible.com/u/Antony_Stone)\
**Post date:** [June 17, 2022, 9:56am UTC](https://forum.ansible.com/t/file-date-time-stamps/36748/1 "2022-06-17T09:56:13Z")

</div>

Hi.

I have a generic question about ansible, and the way it manages files on target  
(managed) systems. They're all Linux systems.

I'm working in an environment where a colleague is running ansible scripts to  
manage servers I work with, and I see that every time ansible runs, it updates  
date and time stamps on files it is managing, even when the content is already  
correct and isn't being changed.

Is this a standard feature of ansible and the way it does configuration  
management, or does it suggest that there's something incorrect or at least  
inefficient about the way it's being used here?

I'm really not familiar with ansible myself, but I have used puppet in the  
past, and that didn't do this - if a file was already correct it did not get  
touched.

Thanks for any advice.

Antony.

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [June 17, 2022, 12:24pm UTC](https://forum.ansible.com/t/file-date-time-stamps/36748/2 "2022-06-17T12:24:23Z")

</div>

No. It's not a standard feature of Ansible. Just the opposite, in  
most cases the goal is to make a playbook idempotent. There should be  
no changes reported when running a playbook repeatedly.

It depends on the module and it might be configurable. For example,  
the module \*file\* allows to preserve \*access\_time\* and  
\*modification\_time\* because you might want to configure them depending  
on your use case.  
[https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file\_module.html](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/file_module.html)

Try to find out which Ansible module(s) is/are causing the troubles.  
The task should report 'changed: true'. For example, the task below  
(running at localhost only)  
&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;- file:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: touch  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path: /tmp/test

will repeatedly report 'changed'

&nbsp;&nbsp;TASK [file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
&nbsp;&nbsp;changed: [localhost]

The task will become idempotent when you set both \*access\_time\* and  
\*modification\_time\* to 'preserve'

&nbsp;&nbsp;&nbsp;&nbsp;- file:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state: touch  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;path: /tmp/test  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;access\_time: preserve  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modification\_time: preserve

To move on, it will be necessary to learn details.
