Disable hosts for management

Is there any way to “park” hosts in foreman? Or hide some hosts from the general lists?

We currently have a number of servers which we shut down for a while to reduce power consumption in our data center. We don’t want to delete them from foreman/katello just want to hide them for the time being until we need them again.

I don’t think there is any option for this currently. I know we can handle that with host collections and excluding all those servers but occasionally we forget it which causing job failures. It’s also not nice that those servers are counted as “out of sync”.

So a feature to hide hosts or maybe archive them would be nice. I think generally an archive of hosts would be very helpful anyway because currently the only thing we can do is to delete hosts loosing all configuration information we have had for those. Sometimes it’s really helpful if we had a way to look up the exact parameters and puppet settings we have used on a deleted host when setting up a new one…

Archived hosts do not make sense in general, but if you would call it maintenance mode or downtime I would say the feature sounds reasonable and useful.

But until we have this feature you would need a workaround. The best thing I can come up with as an idea would be a parameter which could be used in jobs to filter which is not much better than what you already have and does not solve the “out of sync”.

We are using the notification/configuration status for this currently.

I believe there is currently no way in the new UI to set that (or at least I could not find it on Foreman 3.16) but you can set it via the legacy UI or via the API.

In the legacy UI:

  • All Hosts page
  • Switch to Legacy UI via kebab menu
  • Select the hosts checkboxes for the hosts you want to disable
  • From the “Select Action” dropdown select “Disable Notifications”
  • With the “Enable Notifications” action you can switch that back

Alternatively, via API:
Endpoint https://<yourforeman>/api/hosts/<hostname>
Payload:

{
  "host": {
    "enabled": false
  }
}

This will not remove the hosts completely, but it does give you a better way to filter and fixes the “out of sync” issue.
Hosts in this status are counted under “Hosts with alters disabled” and you can relatively easily filter them in REX etc queries with status.enabled = true (for active hosts) or status.enabled = false (for disabled hosts).

This is by no means a perfect solution, but it is something that has worked rather well for us for a couple of years now.

1 Like

Thanks. I did not see that. It’s also on the Edit - Additional Information tab of a host. Great.

It’s not ideal but I guess we’ll get used to it to always add a “status.enable = true” to our searches in jobs.

2 Likes

It was added recently to All Hosts bulk actions in 3.19: Fixes #39181 - Add "Manage notifications" bulk action by LadislavVasina1 · Pull Request #10919 · theforeman/foreman · GitHub

3 Likes