# add\_host and variable mass-population

**URL:** <https://forum.ansible.com/t/add-host-and-variable-mass-population/18303>\
**Category:** Ansible Project\
**Created:** [May 25, 2015, 10:00pm UTC](https://forum.ansible.com/t/add-host-and-variable-mass-population/18303 "2015-05-25T22:00:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimon](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Dimon](https://forum.ansible.com/u/Dimon)\
**Post date:** [May 25, 2015, 10:00pm UTC](https://forum.ansible.com/t/add-host-and-variable-mass-population/18303/1 "2015-05-25T22:00:37Z")

</div>

I have a dilemma: I’ve got a module that can produce list of sites that given app is configured to serve, “app\_info” which produces JSON output like this:

`  
“site\_info”: {  
“[some.site.com](http://some.site.com)”: {  
“dataroot”: “/var/lib/app-instances/some\_site”,  
“dbname”: “some\_site”,  
“ip”: “1.2.3.4”,  
“status”: “No”  
},

`

so I’m collecting this data from the “[web]” servers using “data\_collect” role:

`

- name: collect sites info  
app\_info: list  
register: site\_info

- debug: var=site\_info

- name: register sites  
add\_host: name={{ item.key }} group=sites {{ item.value }}  
with\_dict: site\_info

`

as you can see I’m trying to initialize new group “sites” which is working fine, except population of variables per site. How can I grab vars from site\_info for specific site and populate that site’s “facts” with them in the most efficient way? set\_fact seems to be cumbersome a bit, can I somehow convince add\_host to take already arranged vars and assign them to my site?
