# Best way to organize variables that are used by multiple roles

**URL:** <https://forum.ansible.com/t/best-way-to-organize-variables-that-are-used-by-multiple-roles/27674>\
**Category:** Ansible Project\
**Created:** [May 31, 2018, 2:27pm UTC](https://forum.ansible.com/t/best-way-to-organize-variables-that-are-used-by-multiple-roles/27674 "2018-05-31T14:27:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![smalleni](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@smalleni](https://forum.ansible.com/u/smalleni)\
**Post date:** [May 31, 2018, 2:27pm UTC](https://forum.ansible.com/t/best-way-to-organize-variables-that-are-used-by-multiple-roles/27674/1 "2018-05-31T14:27:03Z")

</div>

Hi all,

Our project has several roles that make use of the same variables. Looks like the best practice to organize roles is to place each of these variables in the roles//defaults/main.yml or roles//defaults/main.yml. However, it becomes tedious for a user to change the same variable across several files. What is the best way to organize such variables so that user can toggle it at one place? Currently we do it in group\_vars/all.yml, but not sure if that is the best place.

---

<div class="post-metadata">

**Author:** ![Mauricio\_Tavares](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@Mauricio\_Tavares](https://forum.ansible.com/u/Mauricio_Tavares)\
**Post date:** [May 31, 2018, 2:45pm UTC](https://forum.ansible.com/t/best-way-to-organize-variables-that-are-used-by-multiple-roles/27674/2 "2018-05-31T14:45:17Z")

</div>

I am not the ansible expert here; my posts here clearly showed that.  
What I do is break it apart putting the more global stuff that is  
related to your setup in group\_vars (ex: all your webservers have a  
basic initial setup) and then stuff specific to a given machine might  
be in the playbook entry for said machine. Probably it can be done  
better.
