Thanks Jose for your answer.
The note from the doc is quite vague in my opinion. I would understand that
class c1 {
class { 'c2' : }
require "c3"
}
effectively mixes the two behaviors, but
class { 'c1' : }
class c1 {
require "c2"
}
should not be a case of mixed behavior. The following is equally incorrect
then?
class { 'c1' : }
class c1 {
anchor { 'c1::begin' } ->
class { 'c2' : }
}
class c2 {
require "c3"
}
What if I have 2 classes coming from 2 modules, one that needs parameters,
the other that don't but uses a require:
class moduleA( $param1 ) {
}
class moduleB {
require "someOtherClass"
}
class myClass {
class { 'moduleA': param1 => 'stuff' }
# oops... mixing the two behaviors...
class { 'moduleB' : }
# should be
# require 'moduleB'
# but that would mix the two behaviors as well...
}
Bruno
On Wednesday, April 2, 2014 11:36:34 AM UTC+2, Jose Luis Ledesma wrote:
>
> hi,
>
>
> from:
>
>
> http://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html#declaring-classes<http://www.google.com/url?q=http%3A%2F%2Fdocs.puppetlabs.com%2Fpuppet%2Flatest%2Freference%2Flang_classes.html%23declaring-classes&sa=D&sntz=1&usg=AFQjCNGP3bI3jU2OiKsOUniCn3-a1pHIuA>
>
> Include-Like vs. Resource-Like
>
> Puppet has two main ways to declare classes: include-like and
> resource-like.
>
> *Note:* These two behaviors *should not be mixed* for a given class.
> Puppet’s behavior when declaring or assigning a class with both styles is
> undefined, and will sometimes work and sometimes cause compilation failures.
>
>
> regards,
>
>
> On Tue, Apr 1, 2014 at 2:15 PM, Bruno Bieth <[email protected]<javascript:>
> > wrote:
>
>> Hi,
>>
>> I've got the following code that works as expected:
>>
>> class { "c1": }
>> class { "c2": }
>>
>> class c1 {
>> notice "+++"
>> }
>>
>> class c2 {
>> require "c1"
>> notice "+++"
>> }
>>
>> But switching the declaration order of class c1 and c2:
>>
>> class { "c2": }
>> class { "c1": }
>>
>> class c1 {
>> notice "+++"
>> }
>>
>> class c2 {
>> require "c1"
>> notice "+++"
>> }
>>
>> produces the following error:
>>
>> Notice: Scope(Class[C1]): +++
>> Notice: Scope(Class[C2]): +++
>> Error: Duplicate declaration: Class[C1] is already declared; cannot
>> redeclare at /vagrant/files/aa.pp:4 on node ubuntu1310.nestle.com
>> Error: Duplicate declaration: Class[C1] is already declared; cannot
>> redeclare at /vagrant/files/aa.pp:4 on node ubuntu1310.nestle.com
>>
>> Shouldn't puppet be declarative and insensitive to the declaration order?
>>
>> Bruno
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/puppet-users/f2766983-529b-4fd7-a3c0-6f48efd45f25%40googlegroups.com<https://groups.google.com/d/msgid/puppet-users/f2766983-529b-4fd7-a3c0-6f48efd45f25%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> José Luis Ledesma
>
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/eb2931f1-c74e-4401-a917-f4e02d2dfe5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.