# Use --extra-vars with .json file as input but per host

**URL:** <https://forum.ansible.com/t/use-extra-vars-with-json-file-as-input-but-per-host/16861>\
**Category:** Ansible Project\
**Created:** [November 24, 2014, 11:19am UTC](https://forum.ansible.com/t/use-extra-vars-with-json-file-as-input-but-per-host/16861 "2014-11-24T11:19:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marc\_Roelofs](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Marc\_Roelofs](https://forum.ansible.com/u/Marc_Roelofs)\
**Post date:** [November 24, 2014, 11:19am UTC](https://forum.ansible.com/t/use-extra-vars-with-json-file-as-input-but-per-host/16861/1 "2014-11-24T11:19:20Z")

</div>

HI All,

Not sure how to put this in writing … hopefully I can make my point clear.

We use ansible for many different hosts to setup basic stuff like ntp/ssh access keys etc …  
What I would like to do ( and what works for 1 host ) :  
Create json variable files per host with contents for local facts and motd filling of that specific host

Commandline : ansible-playbook -i ‘my-targeted-host,’ all.yml --extra-vars “@hosts/my-targeted-host.json”

This fills up several variables define throughout the playbook with multiple roles  
Question 1 : When I omit the json file , I want no changes to be made to the taget system in the variables.

Question 2: I would like to run the playbook against multiple hosts and have the playbook lookup the specific variables per host from these json files (hostname matches .json name)

So in this way I can use these .json files as a “inventory system” and these files can contain info per server like application owner which is placed in /etc/motd, when an owners leaves the company I want to do a subsitute of the name and rerun the playbook and refill the /etc/motd with the new aplication owners name ont the machines with that owner

Hopefully this is clear …  
Pleas let me know what is possible ?

---

<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:** [November 24, 2014, 2:52pm UTC](https://forum.ansible.com/t/use-extra-vars-with-json-file-as-input-but-per-host/16861/2 "2014-11-24T14:52:06Z")

</div>

why not just use host\_vars?

they will always be 'included', so q1 and q2 become mute.

---

<div class="post-metadata">

**Author:** ![Marc\_Roelofs](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Marc\_Roelofs](https://forum.ansible.com/u/Marc_Roelofs)\
**Post date:** [November 25, 2014, 2:21pm UTC](https://forum.ansible.com/t/use-extra-vars-with-json-file-as-input-but-per-host/16861/3 "2014-11-25T14:21:09Z")

</div>

Thanx !!
