git Ansible:如何在一本剧本中的其他主机上运行任务?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32627624/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:24:04  来源:igfitidea点击:

Ansible: how to run task on other host inside one playbook?

gitdeploymentcontinuous-integrationansible

提问by Frexin

I'm writing ansible playbook for one specific goal: i'd like to sync directory on server A-n, but before i should make git pull on server "B". I launch playbook on host A-n (described in inventory). I also have playbook for "git pull" on server B. Is it possible to include one playbook in another? I don't know how, because ansible allow to specify only one host group in beginning of playbook.

我正在为一个特定目标编写 ansible playbook:我想在服务器 An 上同步目录,但在我应该在服务器“B”上进行 git pull 之前。我在主机 An 上启动剧本(在清单中描述)。我在服务器 B 上也有“git pull”的剧本。是否可以在另一个剧本中包含一个剧本?我不知道怎么做,因为 ansible 只允许在剧本开头指定一个主机组。

回答by nghnam

If you want to run a task that's associated with a host, but on different host, you should try delegate_to.

如果要运行与主机关联但在不同主机上的任务,则应尝试delegate_to.