Db:seed task ignores changes in job templates

As title says, when you change something in job templates (in rex, ansible, katello) and run bundle exec rails db:seed, seed will ignore these changes and won’t run.

That’s due to the fact that we don’t look for the changes in job templates at all [0].

I would like to change that, however I’ve found one problem.
In my POC branch [1], I iterate over the plugins and look for job templates in path :plugin_root/app/views/:plugin_name/job_templates/**/*.erb.

However, I quickly realized that not all plugins follows this folder structure, as you can see in the table bellow:

plugin job templates folder
foreman_ansible app/views/foreman_ansible/job_templates
foreman_leapp app/views/foreman_leapp/job_templates
foreman_rex app/views/templates/script
katello app/views/foreman/job_templates

I came up with to ideas how to fix it:

  • Unify job templates folder structure across all plugins
  • New plugin helper method :job_templates_path that would define where each plugin have its own job templates

First approach would be great in terms of unifying plugins, but I can imagine that with changing the folder structure we can do more harm than good.
Second approach requires yet another configuration option for the plugins, however it’s pretty safe and from plugins point of view it’s just one line configuration in register.rb

What I would like to hear from community is what you think about it - should we unify the folder structure, should we add new plugin configuration method or you got better idea how to approach this issue?

[0] foreman_seeder.rb
[1] POC branch

FWIW, at least Katello, REX and Ansible have their own seeders for its Job Templates, so I guess changes to plugins are required either way if you want to standardize this.

Oh, and because you were asking, I guess I’d vote for the later, even if it’s more work.

Yes, I’ll keep them untouched, my idea is to include them to list of files “to watch” in the foreman_seeder, see the POC branch

1 Like