# Common inventory for multiple separate projects/environments?

**URL:** <https://forum.ansible.com/t/common-inventory-for-multiple-separate-projects-environments/19703>\
**Category:** Ansible Project\
**Created:** [November 6, 2015, 11:48am UTC](https://forum.ansible.com/t/common-inventory-for-multiple-separate-projects-environments/19703 "2015-11-06T11:48:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lupu\_Pitkanen](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@Lupu\_Pitkanen](https://forum.ansible.com/u/Lupu_Pitkanen)\
**Post date:** [November 6, 2015, 11:48am UTC](https://forum.ansible.com/t/common-inventory-for-multiple-separate-projects-environments/19703/1 "2015-11-06T11:48:48Z")

</div>

Hi,

I’m responsible for dozens of separate projects or server environments (each containing multiple hosts) and now planning to manage all of them using ansible.

There’s a requirement to have a separate git repository for each environment configuration containing inventory, variables, vault, roles and playbooks belonging to that environment only.

The issue is that I need to have a combined inventory of all hosts from all environments so that I could for example run “ansible all …” command for every single host I manage.

I’m aware of the group feature of the inventory, but I can’t see how I could keep the configuration separated that way.

├── env1

│ │ ├── group\_vars  
│ │ │ └── …  
│ │ │  
│ │ ├── roles  
│ │ │ └── …  
│ │ │  
│ │ ├── CHANGELOG.md  
│ │ ├── README.md  
│ │ ├── hosts  
│ │ └── site.yml  
│ │  
├── env2  
│ │ ├── group\_vars  
│ │ │ └── …  
│ │ │  
│ │ ├── roles  
│ │ │ └── …  
│ │ │  
│ │ ├── CHANGELOG.md  
│ │ ├── README.md  
│ │ ├── hosts  
│ │ └── site.yml  
│ │  
…

Is this kind of layout feasible? I couldn’t find any examples for a scenario like this and would appreciate any best practices for this kind of setup. Thank you.

Best Regards,  
Lupu

---

<div class="post-metadata">

**Author:** ![notification](https://avatars.discourse-cdn.com/v4/letter/n/aca169/32.png) [@notification](https://forum.ansible.com/u/notification)\
**Post date:** [November 6, 2015, 11:35pm UTC](https://forum.ansible.com/t/common-inventory-for-multiple-separate-projects-environments/19703/2 "2015-11-06T23:35:52Z")

</div>

Perhaps this article will help you:

[http://rosstuck.com/multistage-environments-with-ansible/](http://rosstuck.com/multistage-environments-with-ansible/)

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [November 9, 2015, 4:56pm UTC](https://forum.ansible.com/t/common-inventory-for-multiple-separate-projects-environments/19703/3 "2015-11-09T16:56:44Z")

</div>

one thing about the article, its using group vars are PLAY level, not  
at inventory level, which can cause confusion, specially if you move  
the plays to a subdirectory.

---

<div class="post-metadata">

**Author:** ![Lupu\_Pitkanen](https://avatars.discourse-cdn.com/v4/letter/l/3ec8ea/32.png) [@Lupu\_Pitkanen](https://forum.ansible.com/u/Lupu_Pitkanen)\
**Post date:** [November 10, 2015, 8:19pm UTC](https://forum.ansible.com/t/common-inventory-for-multiple-separate-projects-environments/19703/4 "2015-11-10T20:19:04Z")

</div>

Thanks very much for pointing out that article and for the clarification regarding group\_vars.

But I can’t see how I could have a separate dir (and git repo) for each group of hosts?  
Inventories, group\_vars and playbooks seem to be under the same directory structure.

Maybe this is not possible and I need to think other ways to handle all of the hosts at  
the same time, maybe with a separate (duplicated) inventory or so.

---

<div class="post-metadata">

**Author:** ![Jeff1](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@Jeff1](https://forum.ansible.com/u/Jeff1)\
**Post date:** [November 11, 2015, 11:49am UTC](https://forum.ansible.com/t/common-inventory-for-multiple-separate-projects-environments/19703/5 "2015-11-11T11:49:06Z")

</div>

ditto - great pointers for an Ansible newbie like me - @marco, @brian - thanks and kudos
