Recomendations for template management


My team is comprised of 5 people that are constantly changing the templates. Are there any recommendations for how we can back those up and develop using them within a multi member group?


There is the foreman_templates plugin to import from a git repository but I’m not sure if the export functionality was ever implemented. @Marek_Hulan do you happen to know that?

Yes it was

While export is handy for settimg up an initial repo, merge conflicts are possible if some are working in the UI and some in Git. I’d suggest doing all your development in a Git repo, using whatever auth makes sense for your users, and schedule a regular import using the plugin. states it’s not implemented :slight_smile:

Sounds like you need to go here then :wink:

Thanks for your responses. I have implemented the foreman_templates plugin and we are using it. However, we are looking for ideas on how group members can use it effectively. For example, if I’m working on a feature for a set which includes all of the templates needed to generate a successful deployment of an os how would I get the changes for the new feature made in my development set merged with the templates that are actively being used by hosts? We are also trying to figure out how the plugin would help us to test changes before they would be utilized by every box in production ie could I make changes to a template, commit/push to git, import into foreman, test the change somehow that doesn’t totally screw up production provisioning, find out my change would totally screw up prod provisioning, revert my change.

This sounds like a normal Git workflow to me - work in branches, merge finished stuff to master, import master to Foreman either regularly or (better) on commit using a post-commit hook (possibly with auto tests, see below)

The plugin can’t but @Shimon_Shtein was working on a separate solution to this, maybe take a look at this thread from our dev archives. Not sure where it’s up to, hopefully Shim can reply :slight_smile:

Hey @Gwmngilfen, thanks for tagging me!

I don’t think that this use case can benefit from static template analysis (that other thread is about it). But I have some thoughts about the subject.

First, about changes made to both UI and git repo: I have scripts somewhere that extract UI changes and apply them as git commits. If it’s an interesting direction, ping me and I will search for them.

Now about the more complicated problem:

I think with some API/hammer fu it should be possible. What I have in mind:

  • Create a new Hostgroup that will be used to test your new templates.
  • Create a new branch from your production templates git.
  • According to templates documentation, use branch and prefix options to import templates from your new branch with a predefined prefix (you can derive it from branch name for clarity).
  • Now the script fu comes: Associate your newly added templates (they will have a name in form <your_branch_prefix>_<template_name>) with your new hostgroup. You can use API for that or (hopefully) hammer.
  • Change your templates as you wish
  • Push your changes to the branch you have created in previous step in git
  • Import the branch again (with the same prefix of course)
  • Create a test host and assign it the hostgroup you have created earlier
  • Watch your changed templates screw up the test host.
1 Like

@Gwmngilfen and @Shimon_Shtein thanks so much for your suggestions. I think this will help my team and I come up with a viable solution.

1 Like

states it’s not implemented

I don’t see such information in there, I see explicit mentioning of exporting

There is also an export action available.

There’s just no hammer plugin yet. Anyway. sent a PR that fixes the header in README so it’s more obivous. @Gwmngilfen mind to get it in?

@Marek_Hulan nice one, merged.

You’re right, I didn’t read it properly.