小编Gar*_*hop的帖子

ansible delegate_to 不使用库存主机?

我正在尝试使用 ansible 同步在两个遥控器之间复制文件。

我的剧本看起来像:

- hosts: newserver
  tasks:
    - name: Copy images from old to new
      synchronize:
        src: /var/www/production/
        dest: /var/www/production/
      delegate_to: oldserver
Run Code Online (Sandbox Code Playgroud)

newserveroldserver在我的库存文件中定义的。如果我替换oldserver为完整主机名,则 delegate_to 可以工作。否则它会抱怨无法访问。oldserver在其他剧本的其他地方工作得很好。

delegate_to 不使用库存吗?

我得到的错误是:

TASK [Copy images from old to new] *************************************************
fatal: [thr.cs.unc.edu]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ", "unreachable": true}
Run Code Online (Sandbox Code Playgroud)

newserver可以从 到达oldserver。正如我上面所说,如果我在 delegate_to 中更改oldserver为它就可以了。gbserver3.cs.unc.edu

我的主机文件如下所示:

[newserver]
thr.cs.unc.edu
[oldserver]
gbserver3.cs.unc.edu
Run Code Online (Sandbox Code Playgroud)

ansible ansible-playbook

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

ansible ×1

ansible-playbook ×1