'Why is copying a directory with Ansible so slow?
I'm using Ansible to copy a directory (900 files, 136MBytes) from one host to another:
---
- name: copy a directory
copy: src={{some_directory}} dest={{remote_directory}}
This operation takes an incredible 17 minutes, while a simple scp -r <src> <dest>
takes a mere 7 seconds.
I have tried the Accelerated mode, which according to the ansible docs, but to no avail.
can be anywhere from 2-6x faster than SSH with ControlPersist enabled, and 10x faster than paramiko.
Solution 1:[1]
synchronize
configuration can be difficult in environments with become_user
. For one-time deployments you can archive source directory and copy it with unarchive
module:
- name: copy a directory
unarchive:
src: some_directory.tar.gz
dest: {{remote_directory}}
creates: {{remote_directory}}/indicator_file
Solution 2:[2]
Best solution I have found is to just zip the folder and use the unarchive
module.
450 MB folder finished in 1 minute.
unarchive:
src: /home/user/folder1.tar.gz
dest: /opt
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | void |
Solution 2 | hd1 |