# best practice to sync a lot of file in different server

**URL:** <https://forum.ansible.com/t/best-practice-to-sync-a-lot-of-file-in-different-server/29116>\
**Category:** Ansible Project\
**Created:** [November 26, 2018, 3:29pm UTC](https://forum.ansible.com/t/best-practice-to-sync-a-lot-of-file-in-different-server/29116 "2018-11-26T15:29:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cava\_cavamagie](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@cava\_cavamagie](https://forum.ansible.com/u/cava_cavamagie)\
**Post date:** [November 26, 2018, 3:29pm UTC](https://forum.ansible.com/t/best-practice-to-sync-a-lot-of-file-in-different-server/29116/1 "2018-11-26T15:29:19Z")

</div>

i have the necessity to copy a large number of file in a large number of server and to check periodically

now i use a task like this

- name: Synchronization of src on the control machine to dest on the remote hosts usr/lib/nagios/plugins  
copy: src={{ item }} dest=/usr/lib/nagios/plugins/ mode=0755  
with\_fileglob:
- plugins/\*

but take a lot of time (70 file) x 200 server

i have an maven it’s a good idea to create a zip with all the file and manage like a single entities ?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [November 26, 2018, 5:56pm UTC](https://forum.ansible.com/t/best-practice-to-sync-a-lot-of-file-in-different-server/29116/2 "2018-11-26T17:56:13Z")

</div>

Since you appear to be copying everything in a directory you could benefit from using the synchronize module, and also specify a single directory as source, instead of iterating over the items in a glob pattern.

This should speed things up significantly.

Dick

---

<div class="post-metadata">

**Author:** ![cava\_cavamagie](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@cava\_cavamagie](https://forum.ansible.com/u/cava_cavamagie)\
**Post date:** [November 27, 2018, 8:59am UTC](https://forum.ansible.com/t/best-practice-to-sync-a-lot-of-file-in-different-server/29116/3 "2018-11-27T08:59:58Z")

</div>

thank you!  
but all the file in in a repository,  
for you is not better to create a zip a use like an artifcat over nexus or jfrog?  
to speed up push & post

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [November 27, 2018, 10:05am UTC](https://forum.ansible.com/t/best-practice-to-sync-a-lot-of-file-in-different-server/29116/4 "2018-11-27T10:05:40Z")

</div>

I have no idea what you mean by 'all the file in in a repository'. If  
you mean the source of the module, then I don't see how this is  
relevant?  
Also artifcat, nexus, or jfrog don't mean anything to me (neither do  
push & post, in this context).

Your task is about synchronizing a number of nagios plugins in a local  
source directory to a destination directory on your target system.

As for the hint about 'a zip', then I assume you are asking if  
combining individual files into a single archive file would be better.  
This of course depends on what your definition of 'better' is.  
Assuming it includes 'easier to manage', then the answer is no.  
You add a lot of overhead by having to handle the creation and  
unwrapping of the ZIP file.  
It will hence be more work to achieve idempotency (depending if this  
is part of your definition of 'better', but I think it should).

So I would still go for the 'synchronize' module (note that your  
original task actually had that very word in it's name).  
If your scale requires further optimisations, then I would suggest to  
do some tests using different strategies and compare numbers.

Dick

---

<div class="post-metadata">

**Author:** ![cava\_cavamagie](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@cava\_cavamagie](https://forum.ansible.com/u/cava_cavamagie)\
**Post date:** [December 14, 2018, 9:30am UTC](https://forum.ansible.com/t/best-practice-to-sync-a-lot-of-file-in-different-server/29116/5 "2018-12-14T09:30:40Z")

</div>

ook  
thnak you!
