# Staging/Production/Local Inventory Files

**URL:** <https://forum.ansible.com/t/staging-production-local-inventory-files/14716>\
**Category:** Ansible Project\
**Created:** [March 6, 2014, 6:50pm UTC](https://forum.ansible.com/t/staging-production-local-inventory-files/14716 "2014-03-06T18:50:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Goodhouse](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@James\_Goodhouse](https://forum.ansible.com/u/James_Goodhouse)\
**Post date:** [March 6, 2014, 6:50pm UTC](https://forum.ansible.com/t/staging-production-local-inventory-files/14716/1 "2014-03-06T18:50:31Z")

</div>

Hey All,

I currently have three separate inventory files to handle staging, production, and local installs for my project. I’m having difficulty figuring out the best way to configure variables while doing this. One example is that on local and staging servers I need to have nginx run on port 80 and not have varnish install, whereas on production servers I need the port to be 81 and have varnish install. I suppose I could create a host\_var file for each and every server to ensure I set the variable to 80 or 81 where needed, but this seems way overkill.

How have people been handling this?

Thanks!

James

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [March 6, 2014, 7:38pm UTC](https://forum.ansible.com/t/staging-production-local-inventory-files/14716/2 "2014-03-06T19:38:57Z")

</div>

i use group\_vars/all for common defaults, then override in group\_vars/production, my inventory files make all production servers part of production group (qa, staging, same).

---

<div class="post-metadata">

**Author:** ![James\_Martin2](https://avatars.discourse-cdn.com/v4/letter/j/b9e5f3/32.png) [@James\_Martin2](https://forum.ansible.com/u/James_Martin2)\
**Post date:** [March 6, 2014, 7:42pm UTC](https://forum.ansible.com/t/staging-production-local-inventory-files/14716/3 "2014-03-06T19:42:19Z")

</div>

Sounds like group vars would help you out. Make sure you have 3 inventory files, one for each environment. In each one create a parent group (staging, prod or local). In your group\_vars dir below your inventory, have a staging, prod, and local file that would contain the vars for that are specific or need to be overridden. For variable defaults, keep them in group\_vars/all.

example inventory file:

[myservers]  
server1  
server2  
server3

[prod:children]  
myservers

ex:

inventory/  
├── group\_vars  
│ ├── all  
│ ├── local  
│ ├── prod  
│ └── staging  
├── local  
├── prod  
└── staging

---

<div class="post-metadata">

**Author:** ![James\_Goodhouse](https://avatars.discourse-cdn.com/v4/letter/j/54ee81/32.png) [@James\_Goodhouse](https://forum.ansible.com/u/James_Goodhouse)\
**Post date:** [March 6, 2014, 9:25pm UTC](https://forum.ansible.com/t/staging-production-local-inventory-files/14716/4 "2014-03-06T21:25:22Z")

</div>

That’s similar to how I have things setup, but I was missing the piece about the parent group in each inventory file and then having a staging/prod/local group.

I found [this](http://stackoverflow.com/questions/20837850/tailor-ansible-roles-to-environment) article on Stack Overflow that had another solution that I’m currently implementing/playing with. Any thoughts or pros/cons of doing it that way?

Thanks for your help!
