node inheritance

48 views
Skip to first unread message

FirstName LastName

unread,
Mar 15, 2012, 1:13:33 PM3/15/12
to puppet...@googlegroups.com
Hi
 
I have a very simple set up
 
node default {
  #declare classes for all nodes 
  include baseline
  }
node app inherits default {
  include appstuff
  }
 
node web inherits default {
  iclude websutff
 }
 
HOWEVER, I'm getting notification that node "web" is applying class appstuff
how could something like that happen?  Any advice?

Dan White

unread,
Mar 15, 2012, 2:10:33 PM3/15/12
to puppet...@googlegroups.com
More details would help.
This is not enough information to debug.

“Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.”
Bill Waterson (Calvin & Hobbes)

> --
> You received this message because you are subscribed to the Google Groups "Puppet Users" group.
> To post to this group, send email to puppet...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
>

Denmat

unread,
Mar 15, 2012, 4:54:55 PM3/15/12
to puppet...@googlegroups.com
Hi,
Further to that, it is most likely going to be that you have either an include or import statement for the web class.

Grep through your manifest and find out if you have included them in base or app stuff.

Den

Alessandro Franceschi

unread,
Mar 19, 2012, 10:55:10 AM3/19/12
to puppet...@googlegroups.com
Just a quick note, not strictly related to your question
Be careful when including classes with nodes' inheritance: if you set a variable, for example, in the node "web" that is used by classes included in the baseline class, that variable' value will be ignored.
It's a typical "variables scoping issue" that has contributed to the bad reputation of the nodes' inheritance layout.

My rule of thumb is:
Use node's inheritance ONLY to set and override variables, and include classes ONLY at the $hostname node level (at the ned of the inheritance tree)
To avoid duplications you case still include webstuff there and in the webstaff class "include baseline".

Sadly this whole nodes' inheritance use to dynamically override variables will break in the next version of Puppet.
( for more info http://docs.puppetlabs.com/guides/scope_and_puppet.html )

al

Garrett Honeycutt

unread,
Mar 20, 2012, 10:57:17 AM3/20/12
to puppet...@googlegroups.com

I would strongly encourage you to never use inheritance with nodes and
only to use inheritance within a given module[1].

Instead of

node default {


include baseline
}
node app inherits default {
include appstuff
}

I would recommend

node default {}
node app {
include baseline # though, I recommend this is named 'common'
include appstuff
}

[1] - http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance

-g

--
Garrett Honeycutt

206.414.8658
http://puppetlabs.com

Alessandro Franceschi

unread,
Mar 20, 2012, 11:23:29 AM3/20/12
to puppet...@googlegroups.com
Let me disagree :-)
Actually I found the nodes' inheritance model an easy to grasp, mantain and manage way to set and override variables according to whatever grouping logic.
I've used it for almost 5 years, in several different Puppet setups of different scales and it has always fit well.
* Given the precautions to use it ONLY to set and override variables and not to include classes. *

I'm definitively disappointed that I won't be able to use it in the next Puppet version and I'm still struggling to find a decent alternative (suggestions?).
Hiera can be an alternative, and will probably be the "right thing" when is incorporated in the next version, but it has its own cons, imho.

my2c
al

jcbollinger

unread,
Mar 20, 2012, 5:04:33 PM3/20/12
to Puppet Users


On Mar 20, 9:57 am, Garrett Honeycutt <garr...@puppetlabs.com> wrote:
> I would strongly encourage you to never use inheritance with nodes and
> only to use inheritance within a given module[1].
>
> Instead of
>
> node default {
>   include baseline}
>
> node app inherits default {
>   include appstuff
>
> }
>
> I would recommend
>
> node default {}
> node app {
>   include baseline # though, I recommend this is named 'common'
>   include appstuff
>
> }
>
> [1] -http://docs.puppetlabs.com/guides/style_guide.html#class-inheritance


Would you care to explain the reasons for that recommendation? I
acknowledge that it's easy to overdo node inheritance, but it works
fine and has some good use cases. I do typically recommend keeping
node inheritance trees very shallow (two levels, or at most three),
but I've never noticed any general sentiment disfavoring its use
altogether.

Class inheritance is a completely different beast. Its appropriate
uses are few (though they do exist), and people seem much more
inclined to get themselves in trouble there than with node
inheritance.


John
Reply all
Reply to author
Forward
0 new messages