# In a large enviroment, with duplicated stacks, why use group\_vars and host\_vars instead of vars\_files ?

**URL:** <https://forum.ansible.com/t/in-a-large-enviroment-with-duplicated-stacks-why-use-group-vars-and-host-vars-instead-of-vars-files/15744>\
**Category:** Ansible Project\
**Created:** [July 23, 2014, 4:07pm UTC](https://forum.ansible.com/t/in-a-large-enviroment-with-duplicated-stacks-why-use-group-vars-and-host-vars-instead-of-vars-files/15744 "2014-07-23T16:07:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luca\_Carboni](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@Luca\_Carboni](https://forum.ansible.com/u/Luca_Carboni)\
**Post date:** [July 23, 2014, 4:07pm UTC](https://forum.ansible.com/t/in-a-large-enviroment-with-duplicated-stacks-why-use-group-vars-and-host-vars-instead-of-vars-files/15744/1 "2014-07-23T16:07:40Z")

</div>

Hi all,  
I’m fine tuning roles for our farm.  
we started with group\_vars and host\_vars, but it results dispersive, lot of file in group\_vars and more important number of files in host\_vars.  
We changed all to use vars\_files, and now we have 2 files, one for credentials and one for all the other variables.

My question is, we don’t understand how to right use of group\_vars and host\_vars? Because they are in best practices, we there aren’t vars\_files.

thanks all for answers.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 23, 2014, 9:56pm UTC](https://forum.ansible.com/t/in-a-large-enviroment-with-duplicated-stacks-why-use-group-vars-and-host-vars-instead-of-vars-files/15744/2 "2014-07-23T21:56:53Z")

</div>

Not understanding the question but we really love group\_vars/ and host\_vars/ a lot here.

vars\_files is more like if your play wants to bring in variables for that specific play, rather than describing info about those hosts.

---

<div class="post-metadata">

**Author:** ![Luca\_Carboni](https://avatars.discourse-cdn.com/v4/letter/l/4bbf92/32.png) [@Luca\_Carboni](https://forum.ansible.com/u/Luca_Carboni)\
**Post date:** [July 24, 2014, 7:39am UTC](https://forum.ansible.com/t/in-a-large-enviroment-with-duplicated-stacks-why-use-group-vars-and-host-vars-instead-of-vars-files/15744/3 "2014-07-24T07:39:06Z")

</div>

I like group\_vars and host\_vars.

Using group\_vars and host\_vars, we have a lot of files for hosts.  
But, if we use group\_vars, and vars\_files, we can reduce drastically the number of files, in one or two file, one for credentials and one for other variables .  
vars\_files are not described in best practice, why ? why have lot of host\_vars, divided in files for hosts instead of one file included by vars\_files ?  
with vars\_files we can simplify the manitenance.  
So we aren’t understanding the use of host\_vars ?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 24, 2014, 11:04am UTC](https://forum.ansible.com/t/in-a-large-enviroment-with-duplicated-stacks-why-use-group-vars-and-host-vars-instead-of-vars-files/15744/4 "2014-07-24T11:04:01Z")

</div>

If your variable information is about multiple hosts, it belongs in group\_vars not host\_vars. Consider applying more groups if you wish to include them.

vars\_files is definitely subscribed, but most people set variables in roles now, rather than in the play at the top.

You are welcome to use whatever works for you. Every environment is different.
