On Fri, 7 Oct 2011 05:55:34 -0700 (PDT)
jcbollinger jcbollinger wrote:

Hi John,

> You are misunderstanding that Puppet variables' values can never be
> reassigned.  Once a variable has a value, it never changes throughout
> the compilation of that catalog.  This is an aspect of Puppet DSL's
> declarative nature.
> 
> As to how to accomplish what you ask, the usual way would be to use
> the parameter and any other data you want to select the value of a
> *different* variable, and then use that second variable.  The same
> thing is fairly common practice in defined types:
> 
> class common::nrpe($ensure='absent') {
> [...]
> 
> if ($::kernel=='Linux') and ($::lsbmajdistrelease=='6') {
>   $really_ensure = 'present'
> } else {
>   $really_ensure = $ensure
> }
> 
> [...]
> 
> }

Ok, I solved the issue with something like that but I thought it was
some kind of ugly workaround... but if it's common I feel better with my
code.


> While I'm on this topic, I'll throw in that I would find it terribly
> confusing if a class or definition failed to honor my specification
> for a parameter named 'ensure'.  

Sorry John, but I don't understand this point.

> I'd also find it confusing, though
> less so, for the default value of an 'ensure' parameter to be
> 'absent'.  I recommend that you tweak your design a bit so as to not
> leave little traps like those for yourself and others to stumble over
> later.  Or at least document the wazoo out of that thing.

I'm playing with this class. First time I do something like above.
Our production services have a default present, but this one is still
in test and I'd like to test it only on Linux 6., so I was playing with
logic inside new class :-)
 
> John
Many thanks for your reply,
Arnau

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to