Foreman: How to test/render provisioning templates

foremantemplates

I have installed Foreman in a test VM and I want to create some custom kickstart files. I understand that Foreman renders the templates during the host creation. But in case of an error, type, variable that is missing etc, the installation fails.

So, how can I test my templates without actually trying to install a new VM?

Obviously, it's counterproductive to start a new build every time I want to make changes in my templates or snippets.

Best Answer

Above the template editor is a small Preview button - select that, and from the dropdown menu on the right select the host that you wish to render the template for.

A managed host with the same operating system will be needed, so it must be created before previewing the template (set up for provisioning through New Host, not created through Puppet or fact uploads.)

The rendered version of the template will be shown like so:

Edit provisioning template with preview

Select the Input tab again and you can return to editing the template. This all happens without needing to save + re-visit the edit page. No changes are persisted when you preview the rendered template, only when you save.

Also see Foreman 1.9 release highlight - template previews for a short screencast showing the feature.