Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8125177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:43:46+00:00 2026-06-06T06:43:46+00:00

I just came cross puppet inheritance lately. A few questions around it: is it

  • 0

I just came cross puppet inheritance lately. A few questions around it:

  1. is it a good practice to use puppet inheritance? I’ve been told by some of the experienced puppet colleagues Inheritance in puppet is not very good, I was not quite convinced.

  2. Coming from OO world, I really want to understand under the cover, how puppet inheritance works, how overriding works as well.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:43:47+00:00Added an answer on June 6, 2026 at 6:43 am
    1. That depends, as there are two types of inheritance and you don’t mention which you mean.

      1. Node inheritance: inheriting from one node fqdn { } definition to another. This in particular is strongly recommended against, because it tends to fail the principle of least surprise. The classic example that catches people out is this:

        node base {
          $mta_config = "main.cf.normal"
          include mta::postfix  # uses $mta_config internally
        }
        node mailserver inherits base {
          $mta_config = "main.cf.mailserver"
        }
        

        The $mta_config variable is evaluated in the base scope, so the “override” that is being attempted in the mailserver doesn’t work.

        There’s no way to directly influence what’s in the parent node, so there’s little benefit over composition. This example would be fixed by removing the inheritance and including mta::postfix (or another “common”/”base” class) from both. You could then use parameterised classes too.

      2. Class inheritance: the use for class inheritance is that you can override parameters on resources defined in a parent class. Reimplementing the above example this way, we get:

        class mta::postfix {
          file { "/etc/postfix/main.cf":
            source => "puppet:///modules/mta/main.cf.normal",
          }
          service { ... }
        }
        
        class mta::postfix::server inherits mta::postfix {
          File["/etc/postfix/main.cf"]:
            source => "puppet:///modules/mta/main.cf.server",
          }
          # other config...
        }
        

        This does work, but I’d avoid going more than one level of inheritance deep as it becomes a headache to maintain.

      3. In both of these examples though, they’re easily improved by specifying the data ahead of time (via an ENC) or querying data inline via extlookup or hiera.

    2. Hopefully the above examples help. Class inheritance allows for overriding of parameters only – you can’t remove previously defined resources (a common question). Always refer to the resource with a capitalised type name (file { ..: } would become File[..]).

      Also useful is that you can also define parameters to be undef, effectively unsetting them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just came a cross this nice code that makes this scatter matrix plot:
I just came across a weird error: private bool GetBoolValue() { //Do some logic
I just came across few articles, while selecting a wiki for my personal site.
Just came across a place where I'd like to use generics and I'm not
I just came across a very interesting issue. If I use ViewData to pass
I just came across a curious scenario where I want to use removeEventListener() within
I just came across this code and a few Google searches turn up no
I just came across some peculiar behavior with getResourceAsInputStream that I was hoping someone
Just came across this by Chris Coyier - http://css-tricks.com/examples/CSSTabs/ Can anyone explain me, how
Just came across an issue with my Wordpress template that I can't figure out.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.