# Access static variables while using dynamic inventory

**URL:** <https://forum.ansible.com/t/access-static-variables-while-using-dynamic-inventory/28143>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [July 24, 2018, 9:46pm UTC](https://forum.ansible.com/t/access-static-variables-while-using-dynamic-inventory/28143 "2018-07-24T21:46:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Suraj\_D](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@Suraj\_D](https://forum.ansible.com/u/Suraj_D)\
**Post date:** [July 24, 2018, 9:46pm UTC](https://forum.ansible.com/t/access-static-variables-while-using-dynamic-inventory/28143/1 "2018-07-24T21:46:45Z")

</div>

I am trying to use dynamic inventory using AWS Ec2 along with some static variables. I created a directory which contains ec2.py, ec2.ini (aws config files as stated in the docs) and vars.ini (containing my static variables). [https://docs.ansible.com/ansible/latest/user\_guide/intro\_dynamic\_inventory.html#using-inventory-directories-and-multiple-inventory-sources](https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html#using-inventory-directories-and-multiple-inventory-sources) seems to sugggest that passing the path to this directory in the -i argument to ansible-playbook should work. However, I am seeing an undefined variable error when i run the command. What might I be missing?

---

<div class="post-metadata">

**Author:** ![Tchia04](https://avatars.discourse-cdn.com/v4/letter/t/fbc32d/32.png) [@Tchia04](https://forum.ansible.com/u/Tchia04)\
**Post date:** [July 25, 2018, 4:10am UTC](https://forum.ansible.com/t/access-static-variables-while-using-dynamic-inventory/28143/2 "2018-07-25T04:10:51Z")

</div>

A sample playbook with your inventory layout would help.
