How do i remove stale entries of hosts from Foreman?

Problem: : I have tried to delete hosts from foreman UI , cli and also API , its marking hosts as unmanaged but its not cleaning up the hosts from Foreman. The entries still exists

Expected outcome: Hosts should be removed from Foreman DB

Foreman and Proxy versions: 3.8.0

Foreman and Proxy plugin versions:

Distribution and version: Rocky 8.9

Other relevant data:

Hi @shazra,

Are there any errors during host deletion from the UI/Hammer etc?
@jeremylenz :eyes:

Hi @sajha ,

Thanks for replying ,
Are there any errors during host deletion from the UI/Hammer etc? - Thats the things , i am not getting any errors, through hammer i am getting message “Host Deleted” but they are not removed as an entry from foreman. The content-view,lifecycle environment etc all details has been removed from hosts but the entries still exists.

@aruzicka do you know if there’s a setting/mode/etc in Foreman that turns hosts into unmanaged ones after deletion rather than fully deleting the host?

And @shazra – no tracebacks in production.log when trying to delete the host?

No, I don’t think there’s anything like that.

The first thing that comes to mind that could be happening is that:

  1. You delete the host from Foreman
  2. The host gets deleted, but the machine it represents is still alive somewhere
  3. The machine sends its facts back to foreman
  4. The host gets created again from facts

If you look at the audit logs, what do they say about it?

1 Like