Missing audit record for Host Collection changes

Problem:
Missing audit record for Host Collection changes

Expected outcome:

Foreman and Proxy versions:
foreman version 1.24.3
katello version 3.14.1

Foreman and Proxy plugin versions:

Distribution and version:
Linux redhat 7.6

Other relevant data:

Hi @sannour

Adding or removing hosts from a Host Collection is not tracked by the auditing system. The reason is that when you do that, the actual Host Collection record in the database is not modified.

Here’s an example host collection displayed in the console:

=> #<Katello::HostCollection:0x0000000014127370
 id: 2,
 name: "my hostcollection",
 description: nil,
 max_hosts: nil,
 organization_id: 1,
 created_at: Tue, 08 Sep 2020 14:42:13 UTC +00:00,
 updated_at: Tue, 08 Sep 2020 14:42:13 UTC +00:00,
 unlimited_hosts: true>

When a host is added or removed, none of those fields change. Since no changes are made to the HostCollection, an audit is not triggered.

To audit changes to hosts using our existing auditing system, the Katello::HostCollectionHosts model would have to be audited, and would show a create or destroy for every host that is added/removed. This is technically possible but I’d say it’s unlikely to be accepted as a feature request.

As an alternative, you can search the Foreman log/production.log for logs similar to this:

14:52:15 rails.1   | 2020-09-08T14:52:15 [I|app|653c94bb] Started PUT "/katello/api/v2/host_collections/2/remove_hosts?organization_id=1" for 127.0.0.1 at 2020-09-08 14:52:15 +0000
14:52:15 rails.1   | 2020-09-08T14:52:15 [I|app|653c94bb] Processing by Katello::Api::V2::HostCollectionsController#remove_hosts as HTML
14:52:15 rails.1   | 2020-09-08T14:52:15 [I|app|653c94bb]   Parameters: {"id"=>"2", "host_ids"=>[6], "organization_id"=>"1", "api_version"=>"v2", "host_collection"=>{"id"=>"2", "host_ids"=>[6]}}
14:52:15 rails.1   | 2020-09-08T14:52:15 [I|app|653c94bb]   Rendering /home/vagrant/katello/app/views/katello/api/v2/common/bulk_action.json.rabl within katello/api/v2/layouts/resource
14:52:15 rails.1   | 2020-09-08T14:52:15 [I|app|653c94bb]   Rendered /home/vagrant/katello/app/views/katello/api/v2/common/bulk_action.json.rabl within katello/api/v2/layouts/resource (Duration: 1.9ms | Allocations: 2420)
14:52:15 rails.1   | 2020-09-08T14:52:15 [I|app|653c94bb] Completed 200 OK in 42ms (Views: 3.8ms | ActiveRecord: 15.3ms | Allocations: 15334)

Here we can see that a single host, with host_id 6, was removed from HostCollection with id 2.

1 Like

We have some docs on host collections in the open sourced WIP Red Hat guides. https://docs.theforeman.org/master/Managing_Hosts/index-foreman.html#chap-Red_Hat_Satellite-Managing_Hosts-Configuring_Host_Collections
@jeremylenz shall I add a note about this to the docs?

@mcorr Wouldn’t hurt to add a short note, I don’t see why not.

1 Like

Thanks a lot for the answer and the tips

1 Like