【发布时间】:2019-02-28 12:06:26
【问题描述】:
我想在两个远程主机之间同步(复制)文件:.
根据我的剧本,我在多个组上运行我的任务,相对于每个任务案例。
我的剧本如下所示:
---
- hosts: myHosts
gather_facts: true
become: true
become_user: "{{ ansi_user }}"
vars:
- buildServer_host : "127.78.11.04"
roles:
#... Different roles
...
- { role: myRole }
我的库存文件如下所示:
[myHosts]
myGroupA
myGroupB
myGroupC
在 myRole 下,我有这个任务:
- name: Copy jars to API server
synchronize:
src: "{{ Workspace_GEN_COLIS }}/{{item.item}}/target/{{item.stdout}}"
dest: "/opt/application/i99was/{{RCD_DEF_VERSION}}/{{item.item}}.jar"
with_items: "{{ jarFileNames.results }}"
when:
- ansible_host in groups['myGroupB']
delegate_to: "{{buildServer_host }}"
如您所见:我想将文件从我的 "buildServer_host" 传输到其他远程目标,该目标仅是组 "myGroupB"
这失败了,我不知道为什么。
好像不明白这个:ansible_host in groups['myGroupB']作为目标主机
建议?
【问题讨论】:
标签: ansible ansible-2.x ansible-inventory ansible-facts