问题
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.
来源:https://stackoverflow.com/questions/43139743/is-nested-yaml-inventory-file-for-ansible-supported