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

**URL:** <https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090>\
**Category:** Ansible Project\
**Created:** [March 28, 2017, 7:45pm UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090 "2017-03-28T19:45:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![F11](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@F11](https://forum.ansible.com/u/F11)\
**Post date:** [March 28, 2017, 7:45pm UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/1 "2017-03-28T19:45:59Z")

</div>

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

---

<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:** [March 30, 2017, 5:08am UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/2 "2017-03-30T05:08:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![F11](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@F11](https://forum.ansible.com/u/F11)\
**Post date:** [March 31, 2017, 1:27am UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/3 "2017-03-31T01:27:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![F11](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@F11](https://forum.ansible.com/u/F11)\
**Post date:** [March 31, 2017, 1:35am UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/4 "2017-03-31T01:35:39Z")

</div>

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

---

<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:** [March 31, 2017, 4:16am UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/5 "2017-03-31T04:16:08Z")

</div>

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](https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/cache)

---

<div class="post-metadata">

**Author:** ![F11](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@F11](https://forum.ansible.com/u/F11)\
**Post date:** [March 31, 2017, 6:32am UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/6 "2017-03-31T06:32:33Z")

</div>

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](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.

---

<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:** [March 31, 2017, 2:39pm UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/7 "2017-03-31T14:39:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![F11](https://avatars.discourse-cdn.com/v4/letter/f/2bfe46/32.png) [@F11](https://forum.ansible.com/u/F11)\
**Post date:** [April 1, 2017, 10:29am UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/8 "2017-04-01T10:29:10Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Mike\_Fennemore](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@Mike\_Fennemore](https://forum.ansible.com/u/Mike_Fennemore)\
**Post date:** [April 1, 2017, 6:17pm UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/9 "2017-04-01T18:17:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Larry\_Smith1](https://avatars.discourse-cdn.com/v4/letter/l/d26b3c/32.png) [@Larry\_Smith1](https://forum.ansible.com/u/Larry_Smith1)\
**Post date:** [April 2, 2017, 4:34am UTC](https://forum.ansible.com/t/how-to-insert-ansible-inventory-out-put-i-e-kernel-info-into-database/24090/10 "2017-04-02T04:34:19Z")

</div>

This may be of some use to you.

[https://github.com/mrlesmithjr/ansible-inventory](https://github.com/mrlesmithjr/ansible-inventory)
