我在我的剧本中使用命令模块,它目前看起来像这样。
- hosts: all
tasks:
- name: Update tar file
command: sudo scp -r username@hostname:/path/from/destination /path/to/destination
Run Code Online (Sandbox Code Playgroud)
出于可读性的目的,我省略了在此任务之前发生的任务,但是当我运行此 playbook 时,它会在此任务处停止。它根本不会前进。我确定这是因为 sudo,所以它可能需要密码。但是,我不确定如何解决这个问题。
您想使用fetch 模块。
- 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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12045 次 |
| 最近记录: |