Hi,
On 04/16/2011 11:56 PM, praddy wrote:
> Hey Guys,
>
> I was experimenting with puppet lang ( as in just learning ), found
> something like below happening, i couldn't explain it to myself so
> thought asking here. I have installed puppet 2.6.7 using rubygems.
>
> here's the manifest:
>
> ====
> $ cat 7.stage_run_example.pp
> stage {"first": before => Stage[main]}
> stage {"last": require => Stage[main]}
>
> class {
> "unix": stage => first;
> "apache": stage => main;
> "praddy": stage => last;
> }
>
> class unix {
> notify{"unix": message => "this is a unix class"}
> }
>
> class apache inherits unix {
> notify{"apache": message => "this is an apache class"}
> }
>
> class praddy inherits apache {
> Notify["apache"] { message => "this is overridden" }
> notify {"praddy": message => "this is a praddy class" }
> }
>
> class param_notify ($message="default message") {
> notify{"$message":}
> }
<snip>
> So, when including the "apache" class i should not be getting the the
> message which is overridden in the "praddy" class, or am i
> interpreting it all wrong?
Your idea of inheritance does not fit the puppet paradigm.
Your "apache" class should not inherit "unix", it may want to include it
(or depend on it, as multiple inclusion is currently not supported for
parameterized classes).
This is an example of inheritance in puppet:
class apache {
package { "apache2-mpm-prefork": ensure => installed }
}
class apache_worker inherits apache {
Package["apache2-mpm-prefork"] { ensure => absent }
package { "apache2-mpm-worker":
ensure => installed,
require => Package["apache2-mpm-prefork"],
}
}
You inherit in class to override some of its resources (and possibly add
some like a different package here), but not much more.
Don't try and build a hierarchy of inherited classes, puppet's
inheritance model is not meant for that (or fit for it).
HTH,
Felix
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.