Ansible:从客户端获取大文件

问题描述 投票:0回答:1

我遇到了 ansible fetch 模块的限制。尝试获取一个稍大的文件 - 1MB 到 250MB 之间 - 这对于获取来说显然太大了。

- name: get result files back
  fetch:
    src: /tmp/file_generated_previous_step.tar.gz
    dest: file_generated_{{ inventory_hostname }}.tar.gz
    flat: yes

当我的结果文件很小时,这可以工作,但当文件大约 1-2MB 时,会出现很长的错误。

我的解决方法是从控制主机 scp 文件,如下所示:

- name: get result files back
  shell: ' scp {{ inventory_hostname }}:/tmp/file_generated_previous_step.tar.gz file_generated_{{ inventory_hostname }}.tar.gz'
  delegate_to: localhost

当我对主机进行没有密码的 pubkey 身份验证时,这工作正常。但没有任何错误处理。

所以我的问题是:是否有正确的方法可以达到相同的结果?约束:Ansible 2.4

最诚挚的问候, 特里福

ansible fetch
1个回答
0
投票

尝试使用同步。它使用 rsync 并且可以毫无问题地处理大文件。

大多数人错过了它可以处理两个方向,包括从服务器到控制器:

mode:

Specify the direction of the synchronization.

In push mode the localhost or delegate is the source.

In pull mode the remote host in context is the source.

Choices:

    "pull"

    "push" ← (default)
© www.soinside.com 2019 - 2024. All rights reserved.