On 10/29/2015 02:24 PM, jcbollinger wrote:
What you describe should not have worked in Puppet 3, either. Class
inheritance is the only mechanism Puppet 3 scoping rules
<https://docs.puppetlabs.com/puppet/3/reference/lang_scope.html> provide
for variables declared in a local scope, such as is established by the
body of a class or a defined type, to be visible in any other scope.
Defined types are not subject to class inheritance. I'm reasonably
confident that the example you provided would create a Notify with an
empty message in Puppet 3, but since you mention templates, there was a
bug in Puppet 3 in which templates were able to access variables via
dynamic scope (PUP-1220)
<https://tickets.puppetlabs.com/browse/PUP-1220>. That would explain
the template behavior you describe.
As far as I know or can tell, scoping rules are unchanged in Puppet 4.
The fix for PUP-1220 was initially rolled out in Puppet 3.5.0, but only
in the future parser. In Puppet 4, the erstwhile future parser is the
only parser.
Damn, that's it then...
There is nothing you can do to cause a variable declared in one defined
type's local scope to be visible in a different defined type. You can
pass its /value/ if you modify the second defined type, but you say you
don't want to do that. The only other avenues I see would involve
modifying the template, or using a different means to specify the target
file's content, or taking a step back and performing a broader
redesign. I'm afraid I can't suggest any details, however, because
you've completely abstracted away what you're actually trying to achieve.
Thanks jcbollinger - you truly are a Puppet hero :)
I seem to have no choice but to merge 2nd level defines into 1st level
define (move templates and all the logic).
Since you really helped, I'll do my best to try and explain what am I
doing here:
1) custom fact detects PHP project working copies in user directories
2) puppet uses custom fact to create defined resources (myclass::mydefined)
3) since each working copy of PHP project needs to generate couple of
apache vhosts, myclass::mydefined would just use apache::vhost define to
create those 3 vhosts per detected working copy
So, only viable solution is obviously to stop using apache::vhost, and
define file {} with templates directly in mclass::mydefined.
Thanks.
--
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/563303F9.4050903%40gmail.com.
For more options, visit https://groups.google.com/d/optout.