# Why my  'hostvars' is undefined ...

**URL:** <https://forum.ansible.com/t/why-my-hostvars-is-undefined/36409>\
**Category:** Ansible Project\
**Created:** [March 8, 2022, 10:30am UTC](https://forum.ansible.com/t/why-my-hostvars-is-undefined/36409 "2022-03-08T10:30:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philippe\_Limouzy](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@Philippe\_Limouzy](https://forum.ansible.com/u/Philippe_Limouzy)\
**Post date:** [March 8, 2022, 10:30am UTC](https://forum.ansible.com/t/why-my-hostvars-is-undefined/36409/1 "2022-03-08T10:30:41Z")

</div>

Hi Evrybody,

I’m facing to a problem that I don’t understand the origin: Any help will be welcome.

I want to use in a playbook a role where the name depends on a variable defined in the inventory.

I have the following dynamic inventory for a host:

the command ansible-inventory -i /etc/ansible/cobbler.py --host “rhel8-test-2” returns:

{  
“cobbler”: {  
…  
“image”: “”,  
“ks\_meta”: {},  
“mgmt\_classes”: [  
“online”,  
],  
“name”: “rhel8-test-2”,  
“netboot\_enabled”: true,  
“power\_user”: “”,  
“profile”: “HWCL\_402”  
}  
}

In my playbook I want to acess to the profile variable =\> “cobbler.profile”: “HWCL\_402”  
The following playbook works fine:

---

<div class="post-metadata">

**Author:** ![rolandm](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/rolandm/32/755_2.png) [@rolandm](https://forum.ansible.com/u/rolandm)\
**Post date:** [March 10, 2022, 7:39pm UTC](https://forum.ansible.com/t/why-my-hostvars-is-undefined/36409/2 "2022-03-10T19:39:35Z")

</div>

Hello,
