Ask Your Question
4

why is inheritance frowned upon?

asked 2013-02-03 11:29:58 -0500

inthedark gravatar image

I guess the title says it all, why is inheritance viewed as a last resort in the Puppet docs?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
9

answered 2013-02-04 15:29:53 -0500

domcleal gravatar image

updated 2013-02-04 15:37:52 -0500

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)

edit flag offensive delete link more

Comments

Great answer, Dom!

eric0 gravatar imageeric0 ( 2013-02-04 17:51:36 -0500 )edit
0

answered 2013-09-24 16:39:27 -0500

spuder gravatar image

updated 2013-09-24 16:40:15 -0500

The puppetlabs learning modules have a great explanation. You can find it in the video about 3:30 in

https://puppetlabs.com/learn/inheritance

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'

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2013-02-03 11:29:58 -0500

Seen: 443 times

Last updated: Sep 24 '13