On Thu, Apr 21, 2011 at 11:45 AM, Jeff Falgout <[email protected]> wrote:
>
>
>
> On Thu, Apr 21, 2011 at 12:13 PM, Nigel Kersten <[email protected]>
> wrote:
>>
>> >
>> > The class:
>> > from rpm_gpg/manifests/init.pp
>> > class rpm_gpg {
>> > include
>> > "rpm_gpg::keys::spacewalk2010",
>> > "rpm_gpg::keys::jpackage"
>> > }
>>
>>
>>
>> root@devlucid:/home/nigel/src/puppet# cat /tmp/test.pp
>> class rpm_gpg::keys::spacewalk2010 {
>> notice("spacewalk class")
>> }
>>
>>
>> root@devlucid:/home/nigel/src/puppet# puppet apply -v /tmp/test.pp
>> notice: Scope(Class[Rpm_gpg::Keys::Spacewalk2010]): spacewalk class
>> notice: Scope(Class[Rpm_gpg::Keys::Jpackage]): jpackage class
>> info: Applying configuration version '1303409507'
>> notice: Finished catalog run in 0.02 seconds
>>
>
>
> Interesting - that also works for me...
> But when I add in a subclass, it only gets executed once:
> # cat test.pp
> class rpm_gpg::keys::spacewalk2010 {
> $string = "SPACEWALK"
> include rpm_gpg::keys
> notice("spacewalk class")
> }
> class rpm_gpg::keys::jpackage {
> $string = "JPACKAGE"
> include rpm_gpg::keys
> notice("jpackage class")
> }
> class rpm_gpg::keys {
> notice("$string")
> notice("this should be included twice")
> }
> class rpm_gpg {
> include
> "rpm_gpg::keys::spacewalk2010",
> "rpm_gpg::keys::jpackage"
> }
> include rpm_gpg
>
> # puppet apply -v test.pp
> notice: Scope(Class[Rpm_gpg::Keys]): SPACEWALK
> notice: Scope(Class[Rpm_gpg::Keys]): this should be included twice
> notice: Scope(Class[Rpm_gpg::Keys::Spacewalk2010]): spacewalk class
> notice: Scope(Class[Rpm_gpg::Keys::Jpackage]): jpackage class
> info: Applying configuration version '1303297974'
> notice: Finished catalog run in 0.07 seconds
>
> I suspect I'm doing something incorrect or misunderstanding something.
Puppet classes are singletons, even if you include a class multiple
times it only realize the resources defined in the class once.
class a {
notify { "hello": }
}
class b {
include a
}
class c {
include a
}
include a
include a, b
include a, c
include b, c
include a, b, c
All declarations above will result in a single instance of class a and
only one notify resource.
Thanks,
Nan
--
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.