Skip to content

Fixes #39892 - Fix templates:cleanup on Foreman 3 - #219

Open
dkelson wants to merge 1 commit into
theforeman:masterfrom
dkelson:fix-templates-cleanup
Open

dkelson wants to merge 1 commit into
theforeman:masterfrom
dkelson:fix-templates-cleanup

Conversation

@dkelson

@dkelson dkelson commented Oct 9, 2026 •

Copy link
Copy Markdown

foreman-rake templates:cleanup fails on current Foreman:

rake aborted!
NameError: uninitialized constant Setting::TemplateSync
Did you mean?  TemplateKind
.../foreman_templates-11.0.1/app/services/foreman_templates/cleaner.rb:10:in `remove_settings'

Setting::TemplateSync no longer exists now that settings live in the registry. The cleaner now deletes any stored template_sync_* rows directly.

While testing I also found the plugin's permissions survive an uninstall. add_all_permissions_to_default_roles puts import_templates, export_templates and view_template_syncs into Manager, Organization admin and Viewer, and they are still there after the cleanup and dnf remove. The cleaner now takes those permissions out of their filters, drops any filter left empty and deletes the permissions.

Tested on Foreman 3.18 / Katello 4.20 (EL9) with foreman_templates 11.0.1: enable the plugin with the installer, disable it, run foreman-rake templates:cleanup, remove the packages and restart. Before this change the rake task aborts and the three permissions remain. With it the task finishes, the permissions and their filters are gone, and hammer ping is clean.

Setting::TemplateSync went away when Foreman moved settings into the
settings registry, so foreman-rake templates:cleanup has been failing
every time with:

  NameError: uninitialized constant Setting::TemplateSync

Delete the stored template_sync_* settings directly. Also remove the
plugin's permissions and the default role filters that held them;
otherwise import_templates, export_templates and view_template_syncs
stay in the database after the plugin is uninstalled.
@dkelson
dkelson force-pushed the fix-templates-cleanup branch from b8fc03c to b73b68c Compare October 9, 2026 22:06
@dkelson dkelson changed the title Fix templates:cleanup on Foreman 3 Fixes #39892 - Fix templates:cleanup on Foreman 3 Oct 9, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant