如何在远程计算机上使用Ansible复制目录

时间:2018-12-01 14:55:05

标签: ansible

我正在尝试使用Ansible复制远程计算机上的目录。

它抛出“ msg”:“远程副本不支持目录的递归副本:”错误。

下面是我的剧本。

  • 名称:复制Juddi相关目录  复制:    src:“ {{source_vm}} / {{item}}”    目标:“ {{destination_vm}} /”    remote_src:是  with_items:     -“ dir1”     -“ dir2”     -“ dir3”

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

您可以使用同步模块https://docs.ansible.com/ansible/latest/modules/synchronize_module.html#examples,只需将copy替换为synchronize

阅读上面的示例链接。对于一台远程主机上的两个目录,使用:

- name: Synchronize two directories on one remote host.
  synchronize:
    src: /first/absolute/path
    dest: /second/absolute/path
  delegate_to: "{{ inventory_hostname }}"
相关问题