# running playbook for windows plus dynamic inventory and dynamic groups\_vars

**URL:** <https://forum.ansible.com/t/running-playbook-for-windows-plus-dynamic-inventory-and-dynamic-groups-vars/18219>\
**Category:** Ansible Project\
**Tags:** windows\
**Created:** [May 13, 2015, 6:17am UTC](https://forum.ansible.com/t/running-playbook-for-windows-plus-dynamic-inventory-and-dynamic-groups-vars/18219 "2015-05-13T06:17:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ritesh\_Shetty](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Ritesh\_Shetty](https://forum.ansible.com/u/Ritesh_Shetty)\
**Post date:** [May 13, 2015, 6:17am UTC](https://forum.ansible.com/t/running-playbook-for-windows-plus-dynamic-inventory-and-dynamic-groups-vars/18219/1 "2015-05-13T06:17:43Z")

</div>

Hi  
I have a requirement to run playbook on hyperv compute nodes (windows) i tried the method mentioned to keep all variables .

ansible\_ssh\_user: Administrator  
ansible\_ssh\_pass: password  
ansible\_ssh\_port: 5986  
ansible\_connection: winrm

I use dynamic inventory to get the target hosts dynamically. Since the hosts are not static and they keep changing i cannot keep the above variables in a static file in group\_vars

Question is can group\_vars be passed as part of the dynamic inventory json ? Can i have a section in \_meta as group\_vars ? if yes what would be the structure ?

{  
“\_meta”: {  
“hostvars”: {  
“192.168.0.68”: {  
“username”: “Administrator”,  
“hypervisor\_type”: “hyperv”,  
“hypervisor\_id\_list”: [  
“2”  
],  
“password”: “password”,  
“port”: “5986”  
}  
}  
},  
“computenodes”: {  
“hosts”: [  
“192.168.0.68”  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![Shaps](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shaps/32/1356_2.png) [@Shaps](https://forum.ansible.com/u/Shaps)\
**Post date:** [May 13, 2015, 7:27am UTC](https://forum.ansible.com/t/running-playbook-for-windows-plus-dynamic-inventory-and-dynamic-groups-vars/18219/2 "2015-05-13T07:27:07Z")

</div>

Hi,

you just have to add “vars” to the group name, so assuming “computenodes” is your group you would have something like:

“computenodes”: {  
“hosts”: [  
“192.168.0.68”  
],  
“vars”:{  
“var1”: “Var”,  
“var2”: 2  
}

}

Have a look here:  
[https://github.com/Shaps/mongo-dynamic-inventory/blob/master/inventory.py#L55](https://github.com/Shaps/mongo-dynamic-inventory/blob/master/inventory.py#L55)

Andrea

---

<div class="post-metadata">

**Author:** ![Ritesh\_Shetty](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@Ritesh\_Shetty](https://forum.ansible.com/u/Ritesh_Shetty)\
**Post date:** [May 14, 2015, 6:24pm UTC](https://forum.ansible.com/t/running-playbook-for-windows-plus-dynamic-inventory-and-dynamic-groups-vars/18219/3 "2015-05-14T18:24:36Z")

</div>

Thank you It works !!
