Is it possible to break an inventory groups file into multiple files?
One of our inventory groups files is getting huge and unwieldy. Is there a way to break groups files into multiple files?
Posted Jul 14, 2017, 4:51 PM UTC
35
One of our inventory groups files is getting huge and unwieldy. Is there a way to break groups files into multiple files?
Posted Jul 14, 2017, 4:51 PM UTC
You can set your inventory in ansible.cfg to be a directory and ansible will use all relevant files in that directory path.
In the defaults section of ansible.cfg:
[defaults]
- inventory = /etc/ansible/hosts
+ inventory = /etc/ansible/inventory_directory
Then put your inventory file(s) into /etc/ansible/inventory_directory/
Yup, use a directory and -i the dir name. They don't even have to be static files, they can also be scripts for dynamic inventory or even a mixture. We have a static inventory file and a dynamic script and ansible uses both
You can break it up. Just use the -i flag when you run ansible-playbook to point to the inventory you want. Does that cover your needs?
Oh, I see. Use multiple inventories, instead of a single inventory with multiple groups?
Yes that's what I was suggesting.