Search code examples
ansible

Fetch zip file from remote host to local takes forever


I have this task in an Ansible playbook:

- name: Copy volumes.zip to local
  fetch: 
    src: "/tmp/volumes.zip"
    dest: "/home/user/volumes/"
    flat: true

It never ends. volumes.zip size is about 500MB. After debugging, I can see connection is done ok. In fact, I have some previous tasks in the same playbook (for generating that volumes.zip file) and they work fine.

What is happening? Is there any alternative to fetch module?


Solution

  • 500Mb file is too big for fetch module. You can either use synchronize module or simple bash commands like rsync or scp.

    Example with synchronize

    - name: Copy volumes.zip to local
       mode: pull
       synchronize:
       src: rsync://host/tmp/volumes.zip
       dest: /home/user/volumes/
    

    Example with scp

    - name: Copy volumes.zip to local
      shell: ' scp remote_server:/home/user/volumes/volumes.zip /tmp/volumes.zip '
      delegate_to: localhost