# Per host vars in inventory script

**URL:** <https://forum.ansible.com/t/per-host-vars-in-inventory-script/13199>\
**Category:** Ansible Project\
**Created:** [July 25, 2013, 11:38pm UTC](https://forum.ansible.com/t/per-host-vars-in-inventory-script/13199 "2013-07-25T23:38:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Victor\_Castell](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@Victor\_Castell](https://forum.ansible.com/u/Victor_Castell)\
**Post date:** [July 25, 2013, 11:38pm UTC](https://forum.ansible.com/t/per-host-vars-in-inventory-script/13199/1 "2013-07-25T23:38:46Z")

</div>

I don’t know how to deal with this.

I have a list of IPs and I want to use ansible\_ssh\_host var to give a short name to a given IP address but I want to use an inventory script like this:

“group1”: {  
“hosts”: [“host1”, “host2”],  
“vars”: { “ansible\_ssh\_host”: “xxx.xxx.xxx.xxx” }  
}

This way I can only set ssh\_host per group not per host and I noticed that it is affecting both hosts.

Is there any way to do this with the inventory script json API?

Thanks

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 26, 2013, 1:30pm UTC](https://forum.ansible.com/t/per-host-vars-in-inventory-script/13199/2 "2013-07-26T13:30:58Z")

</div>

Yes, when the inventory script is called with --host hostname it can return JSON for a specific host.

(There is a RFE open to implement a way to return these in the main return, eliminating the need for the script to make additional calls, but we’ll support both forms indefinitely)

[http://www.ansibleworks.com/docs/api.html#example-the-cobbler-external-inventory-script](http://www.ansibleworks.com/docs/api.html#example-the-cobbler-external-inventory-script)

---

<div class="post-metadata">

**Author:** ![Victor\_Castell](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@Victor\_Castell](https://forum.ansible.com/u/Victor_Castell)\
**Post date:** [July 26, 2013, 10:30pm UTC](https://forum.ansible.com/t/per-host-vars-in-inventory-script/13199/3 "2013-07-26T22:30:27Z")

</div>

Thanks, I can do it that way.

RFE? it’s an open issue? Would be great to save the second roundtrip 🙂

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 26, 2013, 11:21pm UTC](https://forum.ansible.com/t/per-host-vars-in-inventory-script/13199/4 "2013-07-26T23:21:47Z")

</div>

Yes, here’s the github for it: [https://github.com/ansible/ansible/issues/3182](https://github.com/ansible/ansible/issues/3182)
