On Friday, January 22, 2016 at 10:21:21 AM UTC-6, Gerhardus Geldenhuis 
wrote:
 

> I can easily reference the variables from the class and get their values 
> in the EPP template however I can't do it for the defined type without 
> passing variables as part of the epp function call and declaring the 
> variables at the top of the epp template. Why is there a difference in how 
> variables are accessed from a epp template, between a defined type and a 
> class. Am I missing something or is it by design? I am using puppet 4.3.1
>
>
The EPP documentation describes variable access.  In short, the behavior 
you observe is by design.  EPP templates get their own local scope that 
inherits from *node scope* 
<https://docs.puppetlabs.com/puppet/latest/reference/lang_template_epp.html#accessing-variables>,
 
not from the scope in which the template is evaluated (unless that happens 
to be node scope).  This differs from ERB templates, whose local scope 
*does* inherit from the scope in which the template is evaluated 
<https://docs.puppetlabs.com/puppet/latest/reference/lang_template_erb.html#accessing-puppet-variables>.
  
As the docs describe, an EPP's local scope is much like a defined type's.

An EPP template can access any variable not visible from its own scope 
(such as class variables of any class) via that variable's qualified name, 
just like any DSL code can do.  Defined-type instances are resources, 
however; their local variables have no qualified names, so they are 
directly accessible only in the instance's local scope or a scope that 
inherits from it.  Defining parameters for your EPP template is the 
intended way for you to provide for data that vary between one evaluation 
and another within the same catalog-building run.


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 puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/f449b289-7f8c-44b1-88c0-efaab881fd26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to