Reporting from fact cache?

Hello,

I’d like to browse host facts and be able to select hosts to upgrade at a time of my choosing.

AWX has a fact cache, and the stored information from an individual host can be viewed via the web interface or the API (/api/v2/hosts/XXXX/ansible_facts/). It’s a gold mine of data, but I wondered if anyone had put together a tool to summarise or browse the information more easily?

Or is the sort of things that Red Hat Insights is supposed to be used for? In which case, is there an open source equivalent where the facts can be dumped and queried?

Here are a few examples of things I’d like to do. For hosts in a given inventory:

  1. See a table of (ansible_distribution, ansible_distribution_version), with rolled-up counts of the number of hosts for each combination. Expand to see the individual hosts.

  2. List all hosts individually with chosen facts in columns. For example: on Ubuntu boxes, running /usr/lib/update-notifier/apt-check and putting the results into a fact will show how many packages have updates available, and of those, how many are security updates. Another fact can tell me whether /var/run/reboot-required exists.

  3. Have checkboxes to select specific hosts, and a button to run a job against those hosts. For example, the job template could run apt: update_cache=yes upgrade=dist or a reboot action.

Many thanks,

Brian.

P.S. I found https://github.com/ansible/awx-facts-playbooks/blob/master/scan_facts.yml and the corresponding modules under awx/plugins/library/. These just populate facts; I can’t see how those facts get transferred to Insights.

One option we always had in mind if for you use set up the external logger to send facts. You could use an ELK / Elastic stack, but I suspect that even better tools are out there. Good point that it is a gold mine of data, but because the possibilities are so great it’s hard to put together a single presentation to serve everyone’s needs.

I don’t mind if I have to run a playbook to refresh the facts and push them to another store, if that’s better than querying the fact cache directly.

If I could find the mechanism which Insights uses then maybe it could be re-used; otherwise maybe I could use the uri module to post them to some database. That database then needs to have some usable reporting/query/dashboard.

ElasticSearch: hmm, I suppose that would work. I was hoping to avoid a heavyweight Java dependency though :frowning:

Hi

Though this is quite an old thread I’d like to follow up:
We’d also like to re-use the gold mine (information in in the facts cache) for reporting purposes.

My idea was to use a tool like Redash (https://redash.io/) to connect to the AWX postgresql db and make queries and dashboards within Redash.
I read in another thread the AWX db is not meant for external access.
Is that statement correct or is there a way to access the AWX postgresql db from external? If yes, how can I acess the db in a K8s environment with awx-operator?

Best regards,
Phil

The postgres that automatically deploys inside of the AWX cluster is not accessible from the outside. However you could run an external database that you manage, and point AWX to use that database. https://github.com/ansible/awx-operator#external-postgresql-service

What types of information do you want to get from the db for redash? some of that might already be exposed via the API, and we’d also be interested to know what additional data we could make available for users.

Thanks!

AWX Team

Hi

Thanks for your reply.
I meanwhile found out Redash is able to connect with APIs providing JSON as output (…though it does not allow to connect with private IPs for security reasons, which makes me gonna “hmmmm…” )

Anyway, we’re using AWX mainly to configure/automate Windows servers and beside the facts AWX/Ansilbe is per default providing via the API we’re also interested to see installed applications as facts (e.g. to determine if there’s a SQL or Exchange installed and if yes what version).
I’m thinking to generate custom facts with the ansible.builtin.setup module. Do you agree this is the right way?
Best regards,
Phil

Yes this sounds like the right path to getting custom facts to work for your windows servers.

Here the section for doing on linux hosts, there should be something similar for windows although not described in this section (also YT is a good resource for this :slight_smile: )

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_vars_facts.html#adding-custom-facts

AWX Team