PostgreSQL database querrying in AWX

Hello everyone,

I have a requirement in which i have to access and query the PostgreSQL database in AWX for a particular result.

To be specific I want to check after windows update through AWX gui , how many systems having a particular KB number.

How can I accomplish this ie. Querying the database and fetch the result. In which table I can find that data

Please help me out in this , I am new to this AWX and ansible.

Thanks in advance.

This is most definitely NOT the way to use AWX! No one should be querying the database directly.
Check whether KBs are discovered through gather_fact discovery on your windows hosts first off with

ansible winhost.example.com -m setup
Will give you the complete list. Put that in a playbook and run whenever you like to get an up-to-date list.

Hello Phil sir,

First of all, Thanks for your reply.

I ran the command : ansible winhost.example.com -m setup

Its successfully outputting the system info and much more detailed information, but not the KB Installed for a particular system.

My requirement is like:
I am running a windowsPatching playbook against a list of hosts like 50 of them to patch them. So I just want to figure out a particular patch with KBNumber for eg:KB4049065 is installed on how many of those 50 systems. Because logging into every machine and checking the KBNumber would not be meaningful.

That was the reason I asked for whether we can query the db or not.

Any other mehod or solution will also be fine for me. For the above requirement.

If you can please help me out on this.

Thanks in advance and thanks for reply.

So if the KB information isn’t coming back as facts it’s not going to be in the AWX DB.
You’re better off writing a playbook which queries the windows hosts (you might need a little powershell to do this?) and reports that back somewhere, maybe a html file.
That way, you can run to get the up-to-date information regularly as things change. If you use a survey, then you could pass in the KB to be checked.
Make the task repeatable, that’s the point of Ansible :wink:

Hello Phil sir ,

Based on what you told.I did exactly the same . I wrote one powershell script to check the KB number ,ran it using playbook and its working fine.

But do i have to do the same for every requirement which comes ie write one powershell script and run it using ansible playbook. Because at later point of time some more different requirement may comes.

So,was just wondering isn’t it would be great if we can query the Database instead, for the stored data.

Thanks for your suggestion and reply.