inherit vs include classes

734 views
Skip to first unread message

Evan Hisey

unread,
Apr 4, 2008, 5:07:46 PM4/4/08
to puppet...@googlegroups.com
The more I learn the less so things make sense. What exactly is the
difference between including a class and inheriting a class? They seem
to basicly provide the same function. I have looked over this in both
James book and teh puppet website, but I am not getting any clearer on
the difference and in fact may be getting less clear. OOP is not my
forte.

Evan

jtimberman

unread,
Apr 4, 2008, 5:40:00 PM4/4/08
to Puppet Users
You can only override parameters with inheritance. Consider the
following:

class parent {
file { "/tmp/file": ensure => present, mode => 0600, }
}

class child {
File["/tmp/file"] { mode => 755, }
}

include parent, child

Class child cannot override File["/tmp/file"]'s permissions here.
Instead, do this (parent as above)

class child inherits parent {
File["/tmp/file"] { mode => 755, }
}

include child

Note parent does not need to be included, since it is inherited.
Reply all
Reply to author
Forward
0 new messages