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

On Wednesday, 1 April 2020 16:46:42 UTC+1, Dennis McCarthy wrote:
>
> 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
> 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:
>
> mysql> DESCRIBE hosts;
> +----------------+--------------+------+-----+---------+-------+
> | Field          | Type         | Null | Key | Default | Extra |
> +----------------+--------------+------+-----+---------+-------+
> | name           | varchar(255) | YES  |     | NULL    |       |
> | fqdn           | varchar(255) | YES  |     | NULL    |       |
> | main_ip        | varchar(15)  | YES  |     | NULL    |       |
> | os_name        | varchar(80)  | YES  |     | NULL    |       |
> | os_version     | varchar(40)  | YES  |     | NULL    |       |
> | system         | varchar(40)  | YES  |     | NULL    |       |
> | kernel         | varchar(40)  | YES  |     | NULL    |       |
> | arch_hardware  | varchar(12)  | YES  |     | NULL    |       |
> | arch_userspace | varchar(12)  | YES  |     | NULL    |       |
> | virt_type      | varchar(20)  | YES  |     | NULL    |       |
> | virt_role      | varchar(20)  | YES  |     | NULL    |       |
> | cpu_type       | varchar(60)  | YES  |     | NULL    |       |
> | vcpus          | int(11)      | YES  |     | NULL    |       |
> | ram            | float        | YES  |     | NULL    |       |
> | disk_total     | float        | YES  |     | NULL    |       |
> | disk_free      | float        | YES  |     | NULL    |       |
> +----------------+--------------+------+-----+---------+-------+
>
> But not all of the .json fields are available and no custom facts. Maybe I 
> need to play with this a bit more.
>
> *What do I want:*
> I'd love to be able to get a .json host file and import it directly into 
> MySQL. add to the exiting table and be able to run a select statement on 
> it. I guess this is why ansible-cmdb is around because there is nothing 
> that already does this.
>
> Can anyone recommend anyway to store the data so it can be queried on mass?
>
> Any help would be appreciated.
>
> Thanks
> Dennis
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/86e64844-d8d3-48f1-8e40-796fdfaae9ba%40googlegroups.com.

Reply via email to