Parameterized Classes vs Defined Types Discussion

Posted on

I've [somewhat] recently started developing Puppet modules for use with Satellite and have gone through a couple iterations. At first I was developing a large, broadly-scoped module for a specific purpose (i.e. to harden the entire system including configuring numerous service configuration files). I soon found that in order to provide any amount of customizable behavior I would have to provide so many parameters that it was unwieldy.

Therefore, I moved into using much more purpose-specific modules (e.g. sshd, aide, chrony, etc). These modules provide a lot of flexibility and are manageable but then you lose the centralized view of the touchpoints of the larger application or workflow that you might be trying to achieve. On the flipside you now have a better view of all of the configurations relevant to a specific service or configuration file.

I recently came across some modules on the Forge that got me considering using modules with defined types exposing their functionality. I think this seems to be the ultimate way to do things because it allows the same flexibility as the purpose-specific module setup while essentially requiring you to have a dedicated module for your application or workflow to coordinate all of the needed defined type resources.

Personally, I would very much prefer an all or none solution. That is I don't want to have defined type modules for pieces of a workflow but have to directly configure parameters on other modules for other pieces of my workflow. Unfortunately, the module availability on the Forge seems to be about 50/50 at best (that is maybe half the modules are built with defined types). Also, the use of defined types, at least when dealing with config files, essentially means using either Augeas or Concat. For complex configuration files this can often be quite difficult (which I think is why many people default to templates).

So, in order to use the defined type route it would seem that one needs to invest a lot of time in developing custom modules. It seems easier and not [much] worse to just settle for purpose-scecific parameterized modules.

I'm very interested in hearing about other peoples' experiences and recommendations.

Responses