# Use group\_vars with Dynamic Inventory

**URL:** <https://forum.ansible.com/t/use-group-vars-with-dynamic-inventory/21222>\
**Category:** Ansible Developer\
**Created:** [April 20, 2016, 4:23pm UTC](https://forum.ansible.com/t/use-group-vars-with-dynamic-inventory/21222 "2016-04-20T16:23:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajat.gupta712](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/rajat.gupta712/32/4499_2.png) [@rajat.gupta712](https://forum.ansible.com/u/rajat.gupta712)\
**Post date:** [April 20, 2016, 4:23pm UTC](https://forum.ansible.com/t/use-group-vars-with-dynamic-inventory/21222/1 "2016-04-20T16:23:22Z")

</div>

Hello all,

I am trying to use group vars with dynamic inventory file **ec2.py** and It is not working. Can anyone help me how can I use group vars with dynamic inventory?

i am doing like

- hosts: my\_host:tag\_env\_uat

and in group vars, I defined like group\_vars/tag\_env\_uat/vars.yml

the error is

fatal: [192.168.33.10] =\> {‘msg’: “AnsibleUndefinedVariable: One or more undefined variables: ‘dict object’ has no attribute ‘groups’”, ‘failed’: True}  
fatal: [192.168.33.10] =\> {‘msg’: ‘One or more items failed.’, ‘failed’: True, ‘changed’: False, ‘results’: [{‘msg’: “AnsibleUndefinedVariable: One or more undefined variables: ‘dict object’ has no attribute ‘groups’”, ‘failed’: True}]}

FATAL: all hosts have already failed – aborting
