On Thursday, April 18, 2013 4:25:14 AM UTC-5, Matthias Saou wrote:
>
> Hi,
>
> I've been bitten by this quite a few times now, so it got me
> wondering...
>
> When I have both the following classes available :
>
> nagios::client
> mycompany::nagios::client
>
> And I decide to "include nagios::client", things get weird. What I've
> seen is that even if it's from the top scope, puppet can get confused,
> which in turn gets me confused : From inside the "mycompany" module, I
> could understand the ambiguity, but from outside it doesn't make much
> sense (this is with puppet 3.1.1).
>
> Anyway, what does seem to always work is this :
>
> include ::nagios::client
>
> and of course, this also :
>
> class { '::mycompany::nagios::client': ... }
>
> And given how puppet's variable scoping works, it makes most sense. But
> this fully qualified class name syntax isn't present in the
> documentation[1][2], so I'm wondering :
>
> Is this the proper syntax?
>
It is valid syntax.
> Has this (or will this) become the best practice?
>
>
Some people do recommend using absolute names everywhere, but I wouldn't
say it's a consensus best practice. What does seem to be a consensus best
practice is to always refer to classes by (at least) their fully-qualified
names relative to the top scope (i.e. without the initial "::").
You do need the absolute form under some circumstances, however. In
particular, the way name resolution currently works, class name
"nagios::client" in your example will be resolved to
"::mycompany::nagios::client" everywhere inside module "mycompany" (e.g.
inside class mycompany::otherclass, not to mention in
mycompany::nagios::client itself). This applies to references to class
variables, too, I believe. This is because to resolve a non-absolute name,
Puppet starts in the current namespace and checks each containing namespace
in turn, from narrowest to broadest, until it finds the target name.
There is an outstanding issue (I don't recall the number) suggesting that
Puppet's name resolution behavior should be changed. One possibility would
be to remove relative name resolution altogether, and another would be to
skip intermediate namespaces and resolve relative names only against the
local namespace and the top namespace. The idea appears to have some
traction, but as a backward-incompatible change, I don't expect it to be
implemented before Puppet 4.
As for Puppet getting confused, I would be interested in some details --
especially a working example -- if the behavior you observe is not
explained by the name resolution behavior I just described. It may be that
you have discovered a bug.
John
--
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.