On Sunday, April 21, 2013 1:37:40 AM UTC-5, Matthias Saou wrote:
>
> Hi, 
>
> You shouldn't be trying with a variable.



I'm not sure it's fair to say that.  I am a bit surprised that the OP's 
code doesn't work, in fact.  Now, I don't think it's a good idea to do it 
that way, but I suppose it's a model for some more complicated thing that 
the OP is planning.

Some things that might make the example work, either individually or 
jointly, are

   - move the variable declaration to site.pp
   - change the parameter declaration to $config = $::myvar

 

> Here's what you should 
> probably be doing instead : 
>
> /etc/puppet/modules/sensor/manifests/listner.pp 
> define sensor::listner ( $config = 'this is the generic default' ) { 
>     notify { $config : } 
> } 
>
> /etc/puppet/manifests/site.pp 
> Sensor::Listener { config => 'asdf' } 
> node 'dev' { 
>    sensor::listner {"test_sensor":} 
> } 
>
> This would show 'asdf' for all of your nodes, since the default would 
> be set inside site.pp, thus inherited globally. 
>
>

That's a good solution where it applies, but it does have the limitation 
that it's extrinsic instead of intrinsic.

If the default needs to be associated with the definition's module, then a 
different approach is needed.  Before I suggest other alternatives, 
however, I'd like to know more about the objective.  Why does the default 
need to come from a variable?  Who is responsible for assigning the 
variable's value (site admin / module dev / computed by Puppet / ...)?  To 
what does / should the variable belong (overall site / module / some 
specific class / ...)?


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 post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to