Problem: I am trying to find a way to get ALL the changes (audits) that have been performed on a specific host in a specific time period. I have tried using the search filter function in the Foreman GUI, but I am not sure what needs to be typed there. “host = <FQDN_of_host>” doesn’t give me any useful information like:
A puppet class has been removed by this user on this date.
A smart class parameter has been overridden by this user on this date from this value to this value.
This information is present in these audits. I am able to see this information whenever I add/remove a puppet class, whenever I modify smart class parameters etc, but it gets lost over time in the audits history. (which has 222254 pages * 28 entries in my case ).
If I search with “user = <specific_user>” I am able to see all the changes that the user did including the information I am looking for above. Now, I am trying to figure out how to do this per host i.e. see all the changes that have been performed on the host over time by any user on Foreman.
I have also tried using the Foreman API, but it gives me similar information like when I search using the “host = <FQDN_of_host>” filter expression in the Foreman GUI - It doesn’t have all the information about the changes performed on the host.
I just ran into this the other day and was unable to figure out how. Even the “audits” tab when selected from a host itself didn’t really give everything. I don’t have a solution - but am interested in knowing if there is a specific search string that makes it “work” or something that i can document for future use
TL:DR; there’s no easy way to find all related audits like this, but likely easy to add
Tech background and explanation:
The problem here is, that audits are always linked to single resource. The resource can be host, architecture, domain, subnet, puppet class etc. E.g. change of host’s domain means changing one of host’s attribute (foreign key in DB) so it’s easy to track it. For 1:n associations that’s more complicated as the foreign key exists on the “n” side. So you’d probably be able to find audit for update of puppet classes but it’s not linked to the host from which it has been removed. The same for override value, that’s different resource which is not linked to puppet class.
Recently we added a feature for tracking associations. We should be able to start tracking puppet classes assigned to host/host group. Would you mind filing an RFE for this? Or if you’re interested, you can submit a PR, it should be as easy as specifying :associationssimilarly to this to the host model, the association is called :puppetclasses. If you need help with how to submit a patch, here’s a link to a developer handbook.