On Sunday, February 24, 2013 10:27:13 PM UTC-6, James Polley wrote:
>
> We're using ::params classes quite extensively to share values across all 
> classes in a module:
>
> class myclass (
>   $param1 = $myclass::params::param1
> ) inherits myclass::params {
> ... code ...
> }
>
> class myclass::subclass (
>   $param1 = $myclass::params::param1
> ) inherits myclass::params {
> ... code ...
> } 
>
> define myclass::definetype (
>   $param2 = 'value2'
> ) {
>   include myclass::params
>   myvalue = $myclass::params::param1
> }
>
> class myclass::params () {
>   $param1 = 'value'
> }
>
> The goal is that these values can be set in one place and get used 
> everywhere throughout the module.
>
> This works just for for classes inside the module, because the 'inherits' 
> forces the ::params class to be processed first.
>
> However, we consistently run into issues using define types from the 
> module - we can't figure out how to guarantee that the ::params class gets 
> loaded before the define types.
>
>   (Scope(Myclass::Definetype[resourcename])) Could not look up qualified 
> variable 'myclass::params::param1'; class myclass::params has not been 
> evaluated
>
> I'm hoping there's something fairly simple I'm forgetting about that we 
> can use to force the class to be evaluated before any instance of the types.
>

First off, defines are not classes and cannot be treated as such. Defines 
act more like the built in resources - user, file, package etc.

If you need to make sure that your params class gets processed before the 
 defines, you can safely "include myclass::params" in it.

You may also want to look at NOT using inheritance at all for that, and 
instead using "include".  You can pair that with the anchor pattern or 
"anchor-lite" to ensure ordering.

You may also find this article to be quite helpful. It has a good pattern, 
and also shows "anchor 
lite". 
http://www.devco.net/archives/2012/12/13/simple-puppet-module-structure-redux.php

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" 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-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to