storing Ansible facts in mysql database

828 views
Skip to first unread message

Anil Dasmala

unread,
May 2, 2016, 8:26:47 AM5/2/16
to Ansible Project
Hi Guys,

Can someone guide me on how to store the facts for all hosts in inventory into a mysql database.
In other words, output data of setup module to mysql.
Appreciate ideas/suggestions.

--Anil

Brian Coca

unread,
May 2, 2016, 8:46:34 AM5/2/16
to ansible...@googlegroups.com
A fact cache plugin can do this easily, check the memcached and redis ones as an example.


----------
Brian Coca

Uditha Desilva

unread,
May 3, 2016, 3:34:33 AM5/3/16
to Ansible Project
The host facts are dictionary objects and will most likely not have exactly the same number of elements within them (unless you have a trivially uniform environment!) so a MySQL backend isn't a particularly useful fit.

Personally (on Red Hat), I prefer to use the jsonfile backend and a 1 day validity, but specifying a directory under /dev/shm to store the files, thereby effectively running it in a ramdisk. This provides a decent performance gain while still allowing the standard Unix file system security to be applied.

Anil Dasmala

unread,
May 3, 2016, 5:57:37 AM5/3/16
to Ansible Project
thanks for your advice,Brian. Tried redis, so each host (key)and its facts(value) are stored as a key value pair. is there a way I can get the selective facts with in a given key value?.
For example, if I just want to retrieve testhost1's HOSTNAME, ansible_default_ipv4 only, is that possible
Essentially I wanted to parse the selective facts output into a excel/csv with one row per host in easy readable format.

Anil Dasmala

unread,
May 3, 2016, 5:58:26 AM5/3/16
to Ansible Project
Thank you for the ideas, Uditha Desilva.
Reply all
Reply to author
Forward
0 new messages