# design question -- is a 'global' variable indexed by 'inventory\_hostname' an anti-pattern?

**URL:** <https://forum.ansible.com/t/design-question-is-a-global-variable-indexed-by-inventory-hostname-an-anti-pattern/18114>\
**Category:** Ansible Project\
**Created:** [April 28, 2015, 7:30pm UTC](https://forum.ansible.com/t/design-question-is-a-global-variable-indexed-by-inventory-hostname-an-anti-pattern/18114 "2015-04-28T19:30:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cohen.ben](https://avatars.discourse-cdn.com/v4/letter/c/c89c15/32.png) [@cohen.ben](https://forum.ansible.com/u/cohen.ben)\
**Post date:** [April 28, 2015, 7:30pm UTC](https://forum.ansible.com/t/design-question-is-a-global-variable-indexed-by-inventory-hostname-an-anti-pattern/18114/1 "2015-04-28T19:30:17Z")

</div>

I’ve got a design question – I’ve got a somewhat complicated nested yaml object which will specify some parameter values that need to be set differently on different hosts. Prior to this particular case, I’ve been comfortable using the roles system along with host\_vars and group\_vars to represent this kind of host or role-specific variation.

For this particular case though, there are some potential interdependencies between the correct values for these parameters – because of that my instinct is to define a global variable in group\_vars/all.yml indexed by inventory\_hostname. But I could _also_ just override the variable value in host\_vars as normal, but somehow I imagine there will be a time when I need to change these values for multiple hosts at the same time – and somehow it seems more clear to keep these values defined together.

Does defining a variable indexed by ansible\_hostname seem like an anti-pattern? Wondering if my instincts seem sensible to others or not …
