# rsync

**URL:** <https://forum.ansible.com/t/rsync/12679>\
**Category:** Ansible Project\
**Created:** [April 13, 2013, 7:54am UTC](https://forum.ansible.com/t/rsync/12679 "2013-04-13T07:54:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yang\_Zhang](https://avatars.discourse-cdn.com/v4/letter/y/96bed5/32.png) [@Yang\_Zhang](https://forum.ansible.com/u/Yang_Zhang)\
**Post date:** [April 13, 2013, 7:54am UTC](https://forum.ansible.com/t/rsync/12679/1 "2013-04-13T07:54:29Z")

</div>

I'm seeing from various past mailing list exchanges that rsync is the  
suggested course of action for copying a bunch of files.

However, this doesn't seem to really work for deploying files  
throughout the filesystem in places that require root (e.g. various  
files under /etc). We (as I imagine is a common config) don't have  
direct root ssh logins, so simply following what's suggested in the  
docs doesn't work:

&nbsp;&nbsp;local\_action: command rsync -rlp common/files  
{{ansible\_ssh\_user}}@{{inventory\_host}}😕

Any other good approach here? Ideally something that can additionally  
set appropriate ownership of the files after copying the data?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Yang\_Zhang](https://avatars.discourse-cdn.com/v4/letter/y/96bed5/32.png) [@Yang\_Zhang](https://forum.ansible.com/u/Yang_Zhang)\
**Post date:** [April 13, 2013, 7:59am UTC](https://forum.ansible.com/t/rsync/12679/2 "2013-04-13T07:59:25Z")

</div>

(We can just go back to tar-ing all the files over ssh, although if we  
keep up with our ansible hacks like this we seem to just be reverting  
to what our original shell scripts were doing, so we're wondering if  
we're missing anything.)

---

<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:** [April 13, 2013, 1:30pm UTC](https://forum.ansible.com/t/rsync/12679/3 "2013-04-13T13:30:02Z")

</div>

Since you can’t rsync to root locations and need to, a super easy way to do it is to check your content into git and use the git module to redeploy it (or SVN, etc).

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [April 14, 2013, 8:40pm UTC](https://forum.ansible.com/t/rsync/12679/4 "2013-04-14T20:40:23Z")

</div>

Maybe we need two modules, e.g. inflate and deflate, the first creates a tar (delegated if need be) and the second would extract the tar (delegated if need be). Combining these two would allow you to inflate anywhere, and deflate anywhere exactly what you like. It could be one-to-many, or many-to-one, or even many-to-many exactly as you need.

Of course rsync is more versatile in keeping it 'idempotent', but I guess the inflate/deflate modules are very generic, versatile building blocks to do whatever you fancy doing. Even outside of the scope of what rsync does.

---

<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:** [April 14, 2013, 9:12pm UTC](https://forum.ansible.com/t/rsync/12679/5 "2013-04-14T21:12:27Z")

</div>

So inflate is tar, and deflate is tar.

Like the abstraction but curious to what they would do to make them interesting as modules.

(Devil’s advocate mode, I guess.)

---

<div class="post-metadata">

**Author:** ![Marco\_Vito\_Moscarito](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Marco\_Vito\_Moscarito](https://forum.ansible.com/u/Marco_Vito_Moscarito)\
**Post date:** [April 15, 2013, 7:11am UTC](https://forum.ansible.com/t/rsync/12679/6 "2013-04-15T07:11:37Z")

</div>

Maybe it can be a little bit different that simple tar/tar.

We can have servers without direct connection  
localhost -\> A  
localhost -\> B  
A \<- NOT -\> B

inflate: create tar and copy data on localhost  
deflate: copy tar from localhost to remote server  
(this can be required ONLY when direct connection from servers is not  
available, maybe a module parameter)

Another "goodies" can be that tar con just override file, but it don't  
check if a file is changed or not, so we can't use "notify" on action.

---

<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:** [April 15, 2013, 12:46pm UTC](https://forum.ansible.com/t/rsync/12679/7 "2013-04-15T12:46:17Z")

</div>

Checking for files already seems well served by ‘copy’, just make the copy task notify, etc.

Retrieval would be via “fetch”.

---

<div class="post-metadata">

**Author:** ![Marco\_Vito\_Moscarito](https://avatars.discourse-cdn.com/v4/letter/m/97f17d/32.png) [@Marco\_Vito\_Moscarito](https://forum.ansible.com/u/Marco_Vito_Moscarito)\
**Post date:** [April 15, 2013, 4:42pm UTC](https://forum.ansible.com/t/rsync/12679/8 "2013-04-15T16:42:05Z")

</div>

Sure, we can have a "roles" that merge all task and make a simulated  
"rsync" (fetch + copy)..
