Use group_vars with Dynamic Inventory

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