Discovery Plugin does not uninstall cleanly

Discovery plugin was uninstalled via the following process:

# foreman-installer --scenario katello --no-enable-foreman-plugin-discovery
# yum remove tfm-rubygem-foreman_discovery

Post uninstall the Dashboard “Discovered Hosts” widget is still present, displaying an error and cannot be removed:

Additionally Foreman logs errors relating to missing Discovery plugin components.

Expected outcome:

Uninstalling plugin removes all traces of said plugin.

Foreman and Proxy versions:

Katello 3.8.1
Foreman 1.19.1

Other relevant data:

Errno::ENOENT: No such file or directory @ rb_sysopen - /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_discovery-13.0.1/locale/en_GB/LC_MESSAGES/
/usr/share/foreman/log/production.log:File: /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_discovery-13.0.1/locale/en_GB/LC_MESSAGES/

Is there a way to clean this up?

To remove the widget, you can run the following in the foreman-rake console:

Widget.where(template: 'discovery_widget').destroy_all

There will likely be other objects that will need cleaning for complete removal of the plugin from the database, one thing I know of will be the settings:

Setting.where(category: "Setting::Discovered").destroy_all

Let us know if you run into further error messages after that.

Just wondering, why did you decide to stop using the discovery plugin?

1 Like

Cheers @tbrisker, that seems to have done the trick. I’ll keep an eye on the logs for any further issues.

The discovery plugin doesn’t fit our use case. It’s a large, established environment with a lot of VLANs. Previously DHCP was only configured for desktop VLANs and bringing Foreman DHCP into all the server VLANs we need to provision into wasn’t practical so we have configured a couple of dedicated provisioning VLANs that Foreman controls DHCP for.

Almost all our hosts are vSphere guests so this is easy enough to manage and works well. For the couple of physical hosts we have left we’ll look at the bootdisk plugin if need be.