# How to use variables set in inventory file for the hostname /group

**URL:** <https://forum.ansible.com/t/how-to-use-variables-set-in-inventory-file-for-the-hostname-group/30640>\
**Category:** Ansible Project\
**Created:** [June 24, 2019, 2:23pm UTC](https://forum.ansible.com/t/how-to-use-variables-set-in-inventory-file-for-the-hostname-group/30640 "2019-06-24T14:23:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![VS1](https://avatars.discourse-cdn.com/v4/letter/v/bbe5ce/32.png) [@VS1](https://forum.ansible.com/u/VS1)\
**Post date:** [June 24, 2019, 2:23pm UTC](https://forum.ansible.com/t/how-to-use-variables-set-in-inventory-file-for-the-hostname-group/30640/1 "2019-06-24T14:23:37Z")

</div>

Hello

I have this inventory file:

/etc/ansible/inventory/inventory-file

`  
[my-group]  
[myhost.com](http://myhost.com) project=my group=group

[my-group:vars]  
project=my  
group=my-group

`

and this is my playbook

`

- hosts: ‘{{ host }}’  
gather\_facts: yes

roles:

- role: collectd  
vars:  
group: {{ project }}  
project: {{ group }}

`

But for some reason ansible cant read those variables, can i know how i can access this variables ?

`  
  
{% if project == “my” %}  
\<Node “my\_graphite”\>  
Host “my\_host”  
{% elif project == “11” or project == “22” %}  
\<Node “11”\>  
Host “22”

`

I will be using this variables to create a flexible tempalte file
