Puppet node inheritance deprecation

Puppet 4.0 will deprecate node inheritance which is currently a common way to organize resources. I have been using node inheritance to group common configurations into a basic role and then inherit that with a node declaration like the following:

# site.pp
...
node webserver {
  # add all generic web server configuration here
}

node web01 inherits webserver {
  # any custom things that apply to only web01
}
...

This has worked pretty well for me but with a recent update to Puppet 3.7 on a few nodes, I’m getting the following deprecation warning:

Warning: Deprecation notice: Node inheritance is not supported in Puppet >= 4.0.0.
See http://links.puppetlabs.com/puppet-node-inheritance-deprecation

This quickly becomes annoying as puppet runs frequently on the nodes I manage as I like to be able to quickly deploy changes without a kick or other manual intervention, as well as be able to recover quickly if an error were to occur.

To resolve this issue for now, I have modifed all generic nodes and made them into classes and included those classes in the specific node declarations, similar to the following, which is the modified/updated version of what I included above:

# site.pp
...
class webserver {
  # add all generic web server configuration here
}

node web01 {

  # include the generic web server class
  include webserver

  # any custom things that apply to only web01

}
...

Now that works without issuing a deprecation warning which has cleared my inbox quite a bit. The right answer moving forward will be to adhere to the official puppet recommendation of creating modules from these classes and potentially making them parameterized to allow very specific configuration calls from the nodes.

3 thoughts on “Puppet node inheritance deprecation”

  1. Thanks so much for supplying an example! I’ve been looking for an actual solution this, and it’s working great. I wish that puppetlabs deprecation notices in their online docs would follow up with workarounds/kb instead of just detailing the deprecation!

  2. Quick question regarding this.

    We have multiple manfiest files and inside the site.pp file, we import the other manifest files.

    If I only specify the common classes in the site.pp file, will the other manfest files still be able to see them, or would I have to add the common classes into each manifest file?

    Thanks

  3. This depends on how you use puppet. If you use a puppet master then you can simply place all of your manifest files into a directory and when puppet executes it will read all of the manifest files and treat them as a single file. This eliminates the requirement to include or import into site.pp and is an improvement to the process.

    On the other hand, if you use puppet standalone, I have found that you have to continue use of a primary manifest file, such as site.pp. You will then have to create a solution using that file to manage all nodes and classes.

Leave a Reply

Your email address will not be published. Required fields are marked *