# ansible cmdb? Whats the recommended way to store facts for later retrieval?

**URL:** <https://forum.ansible.com/t/ansible-cmdb-whats-the-recommended-way-to-store-facts-for-later-retrieval/32580>\
**Category:** Ansible Project\
**Created:** [April 1, 2020, 3:46pm UTC](https://forum.ansible.com/t/ansible-cmdb-whats-the-recommended-way-to-store-facts-for-later-retrieval/32580 "2020-04-01T15:46:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dennis\_McCarthy1](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Dennis\_McCarthy1](https://forum.ansible.com/u/Dennis_McCarthy1)\
**Post date:** [April 1, 2020, 3:46pm UTC](https://forum.ansible.com/t/ansible-cmdb-whats-the-recommended-way-to-store-facts-for-later-retrieval/32580/1 "2020-04-01T15:46:42Z")

</div>

Hi,

I’m trying to set up a MySQL DB to hold all the ansible facts I produce from “ansible -m setup” (on lots of remote hosts), Store each .json file of each server in a directory but I’m having trouble finding a place to store them.

What do I want to do:  
Well I’ve come from a puppet background, and one of the great things about puppet was puppetDB. I could query the DB for all sorts of facts (from facter including custom facts) and join them together. It was very powerful and I could get answers about my server estate quickly. So what I want is a way to setup the same thing in Ansible. Basically, to know how many of “something” I have in my estate (of 1000+ nodes) without having to use ansible to visit each one to find the answer.

What have I done so far:  
I’ve played with [https://github.com/fboender/ansible-cmdb](https://github.com/fboender/ansible-cmdb)  
It’s a great tool and sort of does what I want but it doesn’t list out all the fields in the DB that are in the .json file.

I get these:

---

<div class="post-metadata">

**Author:** ![ffirg](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/ffirg/32/10029_2.png) [@ffirg](https://forum.ansible.com/u/ffirg)\
**Post date:** [April 1, 2020, 7:23pm UTC](https://forum.ansible.com/t/ansible-cmdb-whats-the-recommended-way-to-store-facts-for-later-retrieval/32580/2 "2020-04-01T19:23:07Z")

</div>

Hi Dennis

Does it have to be MySQL? The reason I ask, is that there are various cache plugins available: [https://docs.ansible.com/ansible/latest/plugins/cache.html#plugin-list](https://docs.ansible.com/ansible/latest/plugins/cache.html#plugin-list)  
One such plugin is, for example, redis. You could use that and then the redis module: [https://docs.ansible.com/ansible/2.5/plugins/lookup/redis.html](https://docs.ansible.com/ansible/2.5/plugins/lookup/redis.html) in playbooks to retrieve facts.

BUT, if you are going to all this trouble, then I would start looking at AWX/Tower as that has inbuilt fact caching. Why reinvent the wheel.

Regards  
Phil.

---

<div class="post-metadata">

**Author:** ![Dennis\_McCarthy1](https://avatars.discourse-cdn.com/v4/letter/d/34f0e0/32.png) [@Dennis\_McCarthy1](https://forum.ansible.com/u/Dennis_McCarthy1)\
**Post date:** [April 1, 2020, 8:12pm UTC](https://forum.ansible.com/t/ansible-cmdb-whats-the-recommended-way-to-store-facts-for-later-retrieval/32580/3 "2020-04-01T20:12:39Z")

</div>

Thanks for your reply Phil.

I tried the redis option for fact caching but I’m not able to query redis for the data, only use it in my playbooks.

I think you’re right though. Its alot of effort so I’ll probably try AWX and see if that fits the bill.

Cheers.
