# accessing variable's in dict file stored in host\_vars

**URL:** <https://forum.ansible.com/t/accessing-variables-in-dict-file-stored-in-host-vars/16945>\
**Category:** Ansible Project\
**Created:** [December 3, 2014, 9:02am UTC](https://forum.ansible.com/t/accessing-variables-in-dict-file-stored-in-host-vars/16945 "2014-12-03T09:02:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amanda\_Galligan](https://avatars.discourse-cdn.com/v4/letter/a/8e7dd6/32.png) [@Amanda\_Galligan](https://forum.ansible.com/u/Amanda_Galligan)\
**Post date:** [December 3, 2014, 9:02am UTC](https://forum.ansible.com/t/accessing-variables-in-dict-file-stored-in-host-vars/16945/1 "2014-12-03T09:02:55Z")

</div>

Currently have a playbook that is creating template configs for our cisco switches. Most generic variables are kept in group\_vars and we're currently using individual host\_var file per switch to store variables unique to each sw e.g hostname, IP address etc..  
Our host\_var structure is as follows:  
host\_vars/tor01.a01  
host\_vars/tor02.a01

Within the INI inventory we reference each switch as follows:  
[cisco\_tor]  
tor01.a01  
tor02.a01

Is it possible to create a single file instead in host\_vars that contains a dict of all switches and access those variables in ansible play instead?  
host\_vars/tor\_switches

Similiar to example looping over hashes given on Ansible documentaion?  
Ive tried to do this by including with\_dict: tor\_switches in playbook but it errors during play run with "with\_dict must contain dict"

Should this be referenced in role/task/main.yml instead?

Amanda
