# Maintain file timestamp during copy

**URL:** <https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12536>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [March 19, 2013, 11:41pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12536 "2013-03-19T23:41:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [March 19, 2013, 11:41pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12536/1 "2013-03-19T23:41:04Z")

</div>

I believe I indicated I was open to making it configurable, if it were  
a global setting.

Send me a patch.

It needs to work for both paramiko and ssh connection types, as well  
as ssh in scp and sftp modes.

---

<div class="post-metadata">

**Author:** ![Antonio\_Messina](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@Antonio\_Messina](https://forum.ansible.com/u/Antonio_Messina)\
**Post date:** [March 20, 2013, 10:42am UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12536/2 "2013-03-20T10:42:11Z")

</div>

> I believe I indicated I was open to making it configurable, if it were  
> a global setting.

I am just curious, why you don't want it to be a module argument like  
group=, owner=, and perm=? It would make much more sense to me...

.a.

---

<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 20, 2013, 2:58pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12536/3 "2013-03-20T14:58:21Z")

</div>

Because you'd have to specify it every time and then would leave it  
out, and also makes your playbook more verbose.

---

<div class="post-metadata">

**Author:** ![Antonio\_Messina](https://avatars.discourse-cdn.com/v4/letter/a/9de053/32.png) [@Antonio\_Messina](https://forum.ansible.com/u/Antonio_Messina)\
**Post date:** [March 20, 2013, 4:09pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12536/4 "2013-03-20T16:09:43Z")

</div>

> > > I believe I indicated I was open to making it configurable, if it were  
> > > a global setting.
> > 
> > I am just curious, why you don't want it to be a module argument like  
> > group=, owner=, and perm=? It would make much more sense to me...
> 
> Because you'd have to specify it every time and then would leave it  
> out, and also makes your playbook more verbose.

That's right, but you could only have \*one\* behaviour at a time, while  
I think that if someone will ever need this option would also like to  
switch it on only for specific files. (again, just for the sake of  
discussion)

.a.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [March 20, 2013, 4:33pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12536/5 "2013-03-20T16:33:08Z")

</div>

preserve=(default false) ? values (times,ctime, owner, group,mode)  
a single item or list of items

another option:

ctime={$item.ctime} user=${item.user} atime= ....  
with\_items: - filename

Implementing both/either should not be hard.

---

<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 20, 2013, 5:48pm UTC](https://forum.ansible.com/t/maintain-file-timestamp-during-copy/12536/6 "2013-03-20T17:48:13Z")

</div>

I'm not open to making it switchable on a per file basis.
