# How to use variables defined in inventory file (hosts) in my playbook?

**URL:** <https://forum.ansible.com/t/how-to-use-variables-defined-in-inventory-file-hosts-in-my-playbook/13932>\
**Category:** Ansible Project\
**Created:** [November 18, 2013, 10:33pm UTC](https://forum.ansible.com/t/how-to-use-variables-defined-in-inventory-file-hosts-in-my-playbook/13932 "2013-11-18T22:33:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kashyap\_Bhatt](https://avatars.discourse-cdn.com/v4/letter/k/f0a364/32.png) [@Kashyap\_Bhatt](https://forum.ansible.com/u/Kashyap_Bhatt)\
**Post date:** [November 18, 2013, 10:33pm UTC](https://forum.ansible.com/t/how-to-use-variables-defined-in-inventory-file-hosts-in-my-playbook/13932/1 "2013-11-18T22:33:41Z")

</div>

Hi,

As the subject says. Here is an example. Based on all my research I was expecting foo and bar to be part of hostvars. I can put host specific variables in separate var files, but I would love to keep them in my inventory file. I don’t want to use it in a template.

bash $  
bash $ cat test\_inv.ini

[foobar]  
someHost foo=“some string” bar=123  
someOtherHost foo=“some other string” bar=456

bash $  
bash $ cat test.yml
