# \[Question\] Do dynamic inventories work with static inventories + group\_vars

**URL:** <https://forum.ansible.com/t/question-do-dynamic-inventories-work-with-static-inventories-group-vars/24479>\
**Category:** Ansible Project\
**Created:** [May 13, 2017, 3:48pm UTC](https://forum.ansible.com/t/question-do-dynamic-inventories-work-with-static-inventories-group-vars/24479 "2017-05-13T15:48:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.barrett\_Strausser](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@j.barrett\_Strausser](https://forum.ansible.com/u/j.barrett_Strausser)\
**Post date:** [May 13, 2017, 3:48pm UTC](https://forum.ansible.com/t/question-do-dynamic-inventories-work-with-static-inventories-group-vars/24479/1 "2017-05-13T15:48:18Z")

</div>

I have a static inventory file similar to

```auto
[production:children]
elasticsearch

[elasticsearch]

```

I have a dynamic inventory file that follows the guidance at

1. [https://www.jeffgeerling.com/blog/creating-custom-dynamic-inventories-ansible](https://www.jeffgeerling.com/blog/creating-custom-dynamic-inventories-ansible)
2. [https://docs.ansible.com/ansible/intro\_dynamic\_inventory.html#dynamic-inventory](https://docs.ansible.com/ansible/intro_dynamic_inventory.html#dynamic-inventory)

I have group\_vars defined for production.

What I was hoping would happen is that the dynamic inventory would pick up the parent groups and in turn pick up the group vars. This is what happens for static inventories.

That is not the case though, I receive undefined errors for the vars defined in production

```auto
- debug: msg="{{ group_names }}"
  tags: [always]

```

but the result is just

TASK [elasticsearch : debug] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
task path: /roles/elasticsearch/tasks/main.yml:2  
ok: [scrubbed] =\> {  
“msg”: [  
“elasticsearch”  
]

---

<div class="post-metadata">

**Author:** ![j.barrett\_Strausser](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@j.barrett\_Strausser](https://forum.ansible.com/u/j.barrett_Strausser)\
**Post date:** [May 13, 2017, 5:28pm UTC](https://forum.ansible.com/t/question-do-dynamic-inventories-work-with-static-inventories-group-vars/24479/2 "2017-05-13T17:28:41Z")

</div>

NVM.

I sorted this out by combining my dynamic and static inventories into a dir, then passing that dir as the -i flag.
