# Maintain file timestamp during copy

**URL:** <https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12533>\
**Category:** Ansible Project\
**Created:** [March 19, 2013, 6:17pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12533 "2013-03-19T18:17:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtovey](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mtovey](https://forum.ansible.com/u/mtovey)\
**Post date:** [March 19, 2013, 6:17pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12533/1 "2013-03-19T18:17:38Z")

</div>

Let me explain a scenario. I have an environment with several hundred servers running in it. We needed to add a few more, and the new servers need to be configured identically to the already existing servers. I have a repository of configuration files and I need to push out files from that repository to the new servers. We want to be able to tell at a glance with ‘ls -l’ that the configuration files on the new servers match the configuration files on the old servers (I am fully aware that this is not an absolute guarantee that the files are truly identical, but it does provide us with reasonable enough satisfaction). There are also other tools, such as ‘find -newer’, etc., that are impacted by the time stamps not being identical.  
So, maintaining the time stamp of a file between its ultimate source and where it is installed in an important expectation. As it is now, after I have installed a file through Ansible, I am going back afterwards and using ‘touch -r’ to change the time stamps of the newly installed files to match that of the source for those files. It seems to me that I should be able to do that with the copy command without the need of this second step.  
-Mark

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [March 19, 2013, 9:57pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12533/2 "2013-03-19T21:57:29Z")

</div>

> > We want to be able to tell at a glance with 'ls -l' that the configuration files on the new servers match the configuration files on the old servers (I am fully aware that this is not an absolute guarantee that the files are truly identical, but it does provide us with reasonable enough satisfaction)

A good way to do this would be to run the playbook with --check and  
see if it recorded the need to make any changes.

---

<div class="post-metadata">

**Author:** ![kahlil.hodgson](https://avatars.discourse-cdn.com/v4/letter/k/b9bd4f/32.png) [@kahlil.hodgson](https://forum.ansible.com/u/kahlil.hodgson)\
**Post date:** [March 21, 2013, 4:15am UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12533/3 "2013-03-21T04:15:11Z")

</div>

If your systems are supposed to be identical, then I think using the command module and 'rsync' is your friend, passing an include file and appropriate arguments.

K
