# Issue Defining hostvars in dynamic inventroy

**URL:** <https://forum.ansible.com/t/issue-defining-hostvars-in-dynamic-inventroy/30878>\
**Category:** Ansible Project\
**Created:** [July 26, 2019, 7:06am UTC](https://forum.ansible.com/t/issue-defining-hostvars-in-dynamic-inventroy/30878 "2019-07-26T07:06:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![priyansh\_setia](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@priyansh\_setia](https://forum.ansible.com/u/priyansh_setia)\
**Post date:** [July 26, 2019, 7:06am UTC](https://forum.ansible.com/t/issue-defining-hostvars-in-dynamic-inventroy/30878/1 "2019-07-26T07:06:56Z")

</div>

I have developed a dynamic inventory which is listing the servers and all servers are grouped according to service been run on the a particular server. eg.if abc is the service name on the group of servers then it is grouped as

“abc”: {  
“hosts”: [  
server1,  
server2

],  
“vars”: {  
}  
}

and then i am fetching the variables related to each server from the sql db and listing them inside the \_meta-\> hostvars-\>server1 in the inventory file only in json format eg.  
“\_meta”: {  
“hostvars”: {  
“server1”: {  
“modified\_username”: “live”,

Now the problem i m facing is when the more then one service is running on the server then if i fetch for the variables from the db then it is updating the existing server1 variable from previous service to the new one

eg.  
if i do a python --list  
it is only displaying variable either of the one service for the particular server as it replacing variable for the service with came first.

I want to list all variable for a particular server even if two services are running on the server.

like this

“\_meta”: {  
“hostvars”: {  
“ **server1** ”: {  
“modified\_username”: “live”,  
}  
“ **server1** ”:{  
“modified\_username”: “kite”,  
}

can someone please help
