# Four Environments, Two Different Config Files

**URL:** <https://forum.ansible.com/t/four-environments-two-different-config-files/17515>\
**Category:** Ansible Project\
**Created:** [February 13, 2015, 11:36pm UTC](https://forum.ansible.com/t/four-environments-two-different-config-files/17515 "2015-02-13T23:36:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Short](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Short](https://forum.ansible.com/u/Chris_Short)\
**Post date:** [February 13, 2015, 11:36pm UTC](https://forum.ansible.com/t/four-environments-two-different-config-files/17515/1 "2015-02-13T23:36:01Z")

</div>

I have four environments (each having their own inventories, host\_vars, and group\_vars). I have a config that’s the same for three of those environments (labs) and a different config for use in the last environment (production). At least two servers in each environment are utilizing this config. I have one role to deploy the bits for all the environments except this one configuration file and I can’t seem to grasp how to handle the one off. Thoughts?

Thanks,  
Chris Short

---

<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:** [February 16, 2015, 2:25pm UTC](https://forum.ansible.com/t/four-environments-two-different-config-files/17515/2 "2015-02-16T14:25:09Z")

</div>

you can set group\_vars at play level, for this config you can still  
have an all and a production file.

---

<div class="post-metadata">

**Author:** ![Chris\_Short](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Short](https://forum.ansible.com/u/Chris_Short)\
**Post date:** [February 16, 2015, 2:27pm UTC](https://forum.ansible.com/t/four-environments-two-different-config-files/17515/3 "2015-02-16T14:27:28Z")

</div>

I am actually in the process of just making a template for each environment. Would you happen to have an example of what you’re talking about? If not, that’s fine.

---

<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:** [February 16, 2015, 2:55pm UTC](https://forum.ansible.com/t/four-environments-two-different-config-files/17515/4 "2015-02-16T14:55:41Z")

</div>

normally you only need 1 template and feed it the different vars, I  
don't have a usable example but it is simply like this:

play.yml  
templates/template.j2  
group\_vars/  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;all  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;production

production will override all for those values, all should have the  
vaules that are common to the 3 envs, production the values for just  
production.

---

<div class="post-metadata">

**Author:** ![Chris\_Short](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@Chris\_Short](https://forum.ansible.com/u/Chris_Short)\
**Post date:** [February 16, 2015, 2:58pm UTC](https://forum.ansible.com/t/four-environments-two-different-config-files/17515/5 "2015-02-16T14:58:27Z")

</div>

Ah, okay. I was overthinking this. Your solution makes sense. Much appreciated!
