# Variables from group\_vars and host\_vars now available to regular /usr/bin/ansible

**URL:** <https://forum.ansible.com/t/variables-from-group-vars-and-host-vars-now-available-to-regular-usr-bin-ansible/12039>\
**Category:** Ansible Project\
**Created:** [October 26, 2012, 11:45pm UTC](https://forum.ansible.com/t/variables-from-group-vars-and-host-vars-now-available-to-regular-usr-bin-ansible/12039 "2012-10-26T23:45:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [October 26, 2012, 11:45pm UTC](https://forum.ansible.com/t/variables-from-group-vars-and-host-vars-now-available-to-regular-usr-bin-ansible/12039/1 "2012-10-26T23:45:00Z")

</div>

I've finally unified these things, after many requests.

For those unfamiliar, assume your inventory file or script is:

/etc/ansible/hosts

This allows for two directories relative to them...

/etc/ansible/group\_vars  
/etc/ansible/host\_vars

Then, for each group the host is in, you can put a YAML file at:

/etc/ansible/group\_vars/groupname  
(don't add an extension)

and can also do:

/etc/ansible/host\_vars/hostname  
(don't add an extension)

This allows you to manage your inventory variables, however nested or  
detailed or structured (hashes of lists of hashes is totally fine!)  
outside of your inventory file, keeping your inventory file nice and  
simple.

Now previously, these variables were just available in playbooks, now  
they are also usable in /usr/bin/ansible.

Remember when referencing variables on the shell command line, you'll  
probably want to escape dollar signs so the shell doesn't eat them.

All the variables are merged such that child groups override as you  
would expect.

--Michael
