【发布时间】:2019-02-08 13:07:17
【问题描述】:
只是想了解您可以使用什么方法将目录从 5-10 个远程主机复制到目标(例如跳转服务器)?
我一直在研究的一个是:
---
- hosts: all
gather_facts: true
vars:
src_path: "/source_path/"
dest_path: "/destination_path/{{ inventory_hostname }}/"
tasks:
- name: Copy a location from REMOTE server to the LOCAL jump box
tags: sync-pull
synchronize:
# The synchronize module forces–delay-updates to avoid leaving a destination in a broken in-between state if the underlying rsync process encounters an error.
src: "{{ src_path }}"
dest: "{{ dest_path }}"
mode: pull # In pull mode the remote host in context is the source.
delete: yes # Delete files in dest that don't exist (after transfer, not before) in the src path. This option requires recursive=yes.
recursive: yes
compress: yes # Default yes. Compress file data during the transfer
times: yes # Preserve modification times
rsync_timeout: 15 # Specify a --timeout for the rsync command in seconds.
rsync_opts:
- "--exclude=.git"
- "--exclude=*.log"
- "--exclude=*.log.gz"
还有许多事情仍在试图弄清楚。其中一些是:
1) 如何确保根据主机选择路径.. 即 Host1 有 3 个 source_path。我不确定这将如何完成!
2) 如果 source_path 没有所需的权限,则脚本失败并出现错误:
send_files 未能打开 \"source_path/iamlog.log\":权限被拒绝 (13)\ 无法弄清楚这里可以做什么!
【问题讨论】:
标签: ansible