我需要从我的库存文件中获取特定的子组并在 ansible playbook 中正确使用它。
all:
children:
development:
children:
ntp_servers:
hosts:
ntp01:
ntp02:
services:
children:
chatbot:
children:
app:
hosts:
chatbot-app01:
chatbot-app02:
db:
hosts:
chatbot-db01:
chatbot-db02:
dice:
children:
app:
hosts:
dice-app01:
dice-app02:
db:
hosts:
dice-db01:
dice-db02:
dice-db03:
redis:
hosts:
dice-redis01:
dice-redis02:
例如,我想抓取聊天机器人组的应用程序子组。谁能举例说明如何引用 chatbot.app 组?
我是这样使用的,但这似乎是错误的陈述。
- hosts: chatbot:app
roles:
- chatbot
无法直接实现您想要实现的目标。您目前遇到的问题是主机组名称app
和db
正在重复,这会影响您的结果。
首先,您需要确保使用唯一的组名。例如:
all:
children:
development:
children:
ntp_servers:
hosts:
ntp01
ntp02
services:
children:
chatbot:
children:
chatbot_app:
hosts:
chatbot-app01:
chatbot-app02:
chatbot_db:
hosts:
chatbot-db01:
chatbot-db02:
dice:
children:
dice_app:
hosts:
dice-app01:
dice-app02:
dice_db:
hosts:
dice-db01:
dice-db02:
dice-db03:
dice_redis:
hosts:
dice-redis01:
dice-redis02:
然后,您可以查看您认为合适的父/子组。使用问题中的示例,您可以执行以下操作:
- hosts: chatbot_app
roles:
- chatbot
您的所有组(开发、ntp_servers、服务、聊天机器人、骰子等)都可以这样做
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句