gpt4 book ai didi

ansible - 如何使用 Ansible 将远程文件复制到本地计算机上?

转载 作者:行者123 更新时间:2023-12-04 00:35:07 25 4
gpt4 key购买 nike

我在我的剧本中使用命令模块,它目前看起来像这样。

- hosts: all

tasks:
- name: Update tar file
command: sudo scp -r username@hostname:/path/from/destination /path/to/destination

出于可读性的目的,我省略了在此任务之前发生的任务,但是当我运行此剧本时,它会在此任务处停止。它根本没有前进。我确定这是因为 sudo,所以它可能需要密码。我不知道如何解决这个问题。

最佳答案

您想使用 fetch module .

- hosts: host.example.com
tasks:
# Copy remote file (host.example.com:/tmp/somefile) into
# /tmp/fetched/host.example.com/tmp/somefile on local machine
- fetch:
src: /tmp/somefile
dest: /tmp/fetched

关于ansible - 如何使用 Ansible 将远程文件复制到本地计算机上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44593915/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com