How do you transfer large files or artifacts efficiently?
IntermediateProductionPerformance and Scale
Answer
Avoid pushing large files from the controller to every host: the controller's bandwidth becomes the bottleneck. Let the targets pull from where the data lives.
- ansible.builtin.get_url:
url: "{{ artifact_url }}" # presigned S3 URL or internal repo
dest: /opt/app/app.tar.gz
checksum: "sha256:{{ artifact_sha256 }}"
- ansible.builtin.unarchive:
src: /opt/app/app.tar.gz
dest: /opt/app/releases/{{ app_version }}
remote_src: true
For directory trees between hosts use synchronize (rsync). Always verify a checksum.
More on Performance and Scale
Why can Ansible be slower than a shell script for 100 servers, and what dominates the time?BeginnerHow do you choose the `forks` value?BeginnerWhat is SSH pipelining and why does it help?BeginnerWhich SSH settings matter for performance and stability?IntermediateHow do you find out which tasks are slow?BeginnerHow do you reduce the cost of fact gathering?Intermediate