Getting variable from a database

Hello,

Well my question is pretty straight forward:
Actually we have tons of information stored on a db and i would like to know if it’s possible to get those and pass them to ansible as hosts/groups vars ?

It’s currently a postgresql db but we’re planning to switch to redis or mongodb.
It would be therefore easier to generate json data structures.

I’ve seen the following syntax in the ansible documentation :
–extra-vars “@some_file.json

So the idea is to run the json generation before ansible execution.

Could please help me to figure out the best option ?
Thanks

Regards,
Smana

Hello,

look at custom inventory scripts:
http://www.ansibleworks.com/docs/intro_dynamic_inventory.html
http://www.ansibleworks.com/docs/developing_inventory.html

Basically, you can write script,that will return values from your database as json and you are done.

David

Cool thank you David,

I’ll have a look at this doc.
I should have search a bit more :stuck_out_tongue:

Regards,
Smana