I'm trying to use a yaml file as inventory file which looks like below:
- prod:
webserver:
hosts:
example1.com
db_servers:
hosts:
example2.com
example3.com
- stag:
webserver:
hosts:
example3.com
It doesn't seem to work, and I couldn't find much info on ansible docs arounf yaml inventory file. Is the above supported?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
No, this is not supported. You are supposed to have different inventories for production/testing.
You can only define single dependency tree like this:
webserver:
hosts:
example1:
db_servers:
hosts:
example2:
example3:
test:
children:
webserver:
db_servers:
In this case group test
is a parent of webserver
and db_servers
.