why is inheritance frowned upon?
I guess the title says it all, why is inheritance viewed as a last resort in the Puppet docs?
There are two types of inheritance in Puppet, nodes and classes.
Node inheritance serves no benefit over composing a node from multiple classes and especially since the advent of parameterised classes, which make it easy to set particular parameters. Hence it's strongly recommended you don't use this feature.
The common mistake in node definitions is to inherit from a base node and then attempt to change the data in the parent node from your specialised node, which isn't possible. Instead, use a single node definition and include parameterised classes, or use an ENC. The node definition docs ... (more)
The puppetlabs learning modules have a great explanation. You can find it in the video about 3:30 in
Reasons you should use inheritance:
- To reduce repetition
Reasons you shouldn't use inheritance:
- Increases coupling
- Increases complexity
- Only useful for overriding resource attributes (not metaparameters)
- Except for resource attributes, every other use case is better accomplished with other methods
- May change behavior of 'ensure' and 'enable'
Asked: 2013-02-03 11:29:58 -0500
Seen: 438 times
Last updated: Sep 24 '13