# Using group\_vars with dynamic inventory groups

**URL:** <https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [February 16, 2015, 3:09pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526 "2015-02-16T15:09:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 16, 2015, 3:09pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/1 "2015-02-16T15:09:01Z")

</div>

for static groups vars to be loaded try adding the group in a static  
file also, even if just empty.

static\_inventory:

[test\_env\_test]

---

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [February 16, 2015, 3:18pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/2 "2015-02-16T15:18:26Z")

</div>

added line to “./inventory/test/test” as suggested:

`

[local]  
localhost target\_environment=“test” dev\_key=“aws-xxx”

[tag\_env\_test]

`

No change. Variable is still not defined.

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [February 16, 2015, 3:24pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/3 "2015-02-16T15:24:19Z")

</div>

loaded after all InventoryParsers are done.

Which ansible version are you using?​

​I think that was a bug in 1.7, solved in 1.8, not sure if backported.​

---

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [February 16, 2015, 3:32pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/4 "2015-02-16T15:32:20Z")

</div>

`

$ ansible --version  
ansible 1.8.2  
configured module search path = None

$ ansible-playbook --version  
ansible-playbook 1.8.2  
configured module search path = None

`

Is there anything else I can show to work out whether I have made a mistake or there is a bug?

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [February 16, 2015, 3:41pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/5 "2015-02-16T15:41:13Z")

</div>

Perhaps if you could put a minimal example in a gist, that reproduces this?​

---

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [February 16, 2015, 4:15pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/6 "2015-02-16T16:15:48Z")

</div>

Edited out a proof of concept from the repo:

[https://github.com/aioue/ansible-test](https://github.com/aioue/ansible-test)

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [February 16, 2015, 6:20pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/7 "2015-02-16T18:20:46Z")

</div>

​I'm afraid I don't have any AWS credentials to test this.  
Can you perhaps provide the plain json dump​ - can be redacted?

---

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [February 16, 2015, 6:39pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/8 "2015-02-16T18:39:15Z")

</div>

Are you looking for the output of the config playbook with -vvvv?

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [February 16, 2015, 6:46pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/9 "2015-02-16T18:46:40Z")

</div>

​no the output of your inventory plugin, which is json​

---

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [February 17, 2015, 6:22pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/10 "2015-02-17T18:22:42Z")

</div>

[https://gist.github.com/aioue/6036fd738f40e8f44a41](https://gist.github.com/aioue/6036fd738f40e8f44a41)

---

<div class="post-metadata">

**Author:** ![Serge\_van\_Ginderacht](https://avatars.discourse-cdn.com/v4/letter/s/b782af/32.png) [@Serge\_van\_Ginderacht](https://forum.ansible.com/u/Serge_van_Ginderacht)\
**Post date:** [February 17, 2015, 7:07pm UTC](https://forum.ansible.com/t/using-group-vars-with-dynamic-inventory-groups/17526/11 "2015-02-17T19:07:59Z")

</div>

Seems I can’t reproduce your problem:

[mstr] serge@cyberlab:~/tmp/ansible-test$ tree  
.  
├── aws-configure.yml  
├── aws-provision.yml  
├── inventory  
│ ├── ec2.py-output.json  
│ └── group\_vars  
│ └── tag\_env\_test.yml  
├── README.md  
└── vars  
├── aws\_secrets.yml  
└── aws\_vars.yml

3 directories, 7 files  
[mstr] serge@cyberlab:~/tmp/ansible-test$ ANSIBLE\_NOCOWS=1 ansible-playbook -i inventory aws-configure.yml

PLAY [!local;tag\_role\_db:&tag\_status\_new] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

TASK: [debug var=groups[‘tag\_env\_test’]] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [54.x] =\> {  
“groups[‘tag\_env\_test’]”: [  
“54.x”  
]  
}

TASK: [debug var={{ region }}] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [54.x] =\> {  
“eu-west-1”: “eu-west-1”  
}

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
54.x : ok=2 changed=0 unreachable=0 failed=0

Tested with ansible 1.7.2, 1.8.2 and latest devel.
