how to insert Ansible inventory out put (i.e kernel info) into database ?

Hi All,
I am very new to Ansible, currently i am trying to evaluate ansible.
i know by using ansible inventory command i can get all information about a system, like ( kernel,Os,network,memory)
but i wanted to insert those information into mysql Database.

i know its possible, but I am looking for some example to see how it can be done. (possible with ansible + python )

can any one please help me with this ? i am looking for some sample module or documentation for this so that i can follow it.

Thanks for the help

Easiest way is using a cache plugin, there are memcached and redis
ones as examples.

Hi Brian,

Thanks for the reply,
would you be able to help me to understand bit moreā€¦

how will it insert to database ?
Thanks for the help

Hi Brian,
from google, i find ansible memcache role plugin, but that seems to create memcached in server.

can you please point out which plugin you are refering ? also how will it help to insert into database ?

Thanks for the help

What you were looking at were modules, here is where the cache plugins live:
https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/cache

Hi Brian,
Thanks, i looked at that module, but still dont understand, how are you inserting data in to a backed database ?

example :-
this module : https://github.com/rishabhdas/dmidecode-ansible
will provide hardware information, but i want to add those into into database for inventory or audit,
how will i accomplish this ?

I just need a basic example of how i can achieve this to understand the bigger picture.

Thanks for the help.

in the case of facts, this happens automatically via cache plugin
(when enabled), if using a specific module that does not return facts,
you have to update the database yourself.

Hi Brian

as you can see i am very new, would you be able to give some example how thats work, i am still looking for some module where the out put will be inserted into database.

can you please help me with this ?

There is also ara available on pypi that has some modules to write to mysql and also gives some useful reporting abilities.

This may be of some use to you.

https://github.com/mrlesmithjr/ansible-inventory