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”: {
“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?