按地区运行Ansible剧本 [英] Run Ansible Playbooks by region

查看:61
本文介绍了按地区运行Ansible剧本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


首先:我仍然是Ansible新手,我已经习惯了.


first of all: I am still an Ansible newbie and I am just getting used to it.

我想写一本根据客户所在位置调出另一本剧本的剧本.

i want to write a playbook that calls up a different playbook depending on the location of the client.

例如:
我有3本专门针对特定地区的剧本,分别是usaclient.yml,euclient.yml和asiaclient.yml

For example:
i have 3 different playbooks specifically for certain regions, usaclient.yml, euclient.yml and asiaclient.yml

这些剧本应通过主剧本"自动执行.

these playbooks should be executed automatically via a "master playbook".

如果在欧洲客户上执行了主剧本",则应启动剧本"euclient.yml".

if the "master playbook" is executed on a european client, the playbook "euclient.yml" should be started.

有人知道如何自动将剧本分配给某个地区吗,还是有一个想法如何通过bash脚本解决此问题?

does anyone know how to assign playbooks automatically to a region or has an idea how to solve this by bash script?

最好的问候
D1Ck3n

best regards
D1Ck3n

推荐答案

Q:如果在欧洲客户上执行了主剧本",则该剧本 euclient.yml 应该是开始."

Q: "If the "master playbook" is executed on a European client, the playbook euclient.yml should be started."

A:在Ansible中,无法有条件地启动剧本.请参见 import_playbook .

A: In Ansible it's not possible to start a playbook conditionally. See import_playbook.

只有2个选项.通过外部工具有条件地启动剧本,或测试剧本内部的状况.尝试 ansible-runner .

There are 2 options only. Start the playbook conditionally by an external tool or test the condition inside the playbook. Try ansible-runner.

这篇关于按地区运行Ansible剧本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆