Ask Your Question
0

How to separate templates from modules?

asked 2013-09-12 07:44:30 -0500

andreas gravatar image

I would like to separate some templates from my modules, so I can provide site specific configurations without modifying the puppet module.

Some applications (e.g. postfix) have lots of parameters to configure. Of course, I can write an awsome template that allows to configure every edge case through class parameters. But a template that handles over 800 parameters is hard to read and even harder to maintain.

What I want is to provide a default template in my module and allow to override it with a site specific template, which is located outside the modules directory structure.

I know ... (more)

edit retag flag offensive close merge delete

Comments

You could pass the template filename as an parameter, but I still don't understand the urgue to have an outside source for that. The problem is that if you ...(more)

golja gravatar imagegolja ( 2013-09-12 08:53:09 -0500 )edit

The filename for the template is relative to the module, not an absolute path. The urge is to provide a custom template, that only needs some parameters for the differences ...(more)

andreas gravatar imageandreas ( 2013-09-13 03:04:39 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-09-13 06:01:01 -0500

nvpuppet gravatar image

Andreas,

When I have had to do something like this in the past, here's the approach I've used. So long as:

  1. the module supports the ability to have a template path passed as a parameter
  2. you have implemented a "site module" (preferably implementing a Roles & Profiles pattern with a templates/ directory

you can drop your site-specific templates into the site module's templates directory. Upgrading the "component-level modules" won't directly change your site-specific templates.

The downside to this approach is that it ties your site module to a particular implementation of your component modules. To implement your ... (more)

edit flag offensive delete link more

Comments

Thanks for your suggestion. I'll give both solutions a try to see what works better for me: a site module that is tied to the component modules or additional ...(more)

andreas gravatar imageandreas ( 2013-09-16 03:00:53 -0500 )edit

Not sure what you mean about that last sentence. Feel free to elaborate. In the meantime, the ability to separate code from data comes via the series of Hiera function ...(more)

nvpuppet gravatar imagenvpuppet ( 2013-09-22 11:17:27 -0500 )edit
1

answered 2013-09-12 12:20:35 -0500

Sneha More gravatar image

updated 2013-09-12 12:30:02 -0500

yes, It will be more easy to have different template for different server rather than passing parameters for each server. And you can pass template name as parameter.

Will you please explain your idea behind keeping default template in module and then override it with a site specific templates?

edit flag offensive delete link more

Comments

The filename for the template is relative to the module, not an absolute path. That's my problem. The default template could provide a config for most of the servers ...(more)

andreas gravatar imageandreas ( 2013-09-13 03:10:57 -0500 )edit

Though the filename is relative to template, you can use the template filename as parameter and you can pass the actual value from site.pp which will be different for ...(more)

Sneha More gravatar imageSneha More ( 2013-09-13 03:34:41 -0500 )edit

So I would add my local template into the modules template directory. What happens when I upgrade the module from puppet forge?

andreas gravatar imageandreas ( 2013-09-13 04:04:22 -0500 )edit

I am not sure about puppet forge. but i don't think it will cause any problem

Sneha More gravatar imageSneha More ( 2013-09-14 06:01:53 -0500 )edit

Thanks for your suggestion. I'll give both solutions a try to see what works better for me: a site module that is tied to the component modules or additional ...(more)

andreas gravatar imageandreas ( 2013-09-16 03:02:14 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2013-09-12 07:44:30 -0500

Seen: 421 times

Last updated: Sep 13 '13