Russ Allbery <r...@stanford.edu> writes:
> Daniel Pittman <dan...@rimspace.net> writes:
>
>> It was, until yesterday, my naive expectation that this would work:
>
>> node default                    { include broken }
>> node "krosp" inherits "default" { $value = "not " }
>> class broken                    { notice("This is ${value}broken") }
>
>> Specifically, I expected this would output 'This is not broken', but instead
>> we get the counter-intuitive and *very* annoying 'This is broken'.
[...]

> Our rule of thumb is that any time one is tempted to set variables and use
> those values in included and inherited classes, that's a red flag that you
> actually wanted a define instead.  If you had instead written this as:
>
> node default { broken { "message": value => "" } }
> node "krosp" inherits "default" { Broken["message"] { value => "not " } }
> define broken($value) { notice("This is ${value}broken") }
>
> I'm pretty sure you'd get the behavior you expected.

I do, indeed.  I don't much like it, as it feels the same sort of work-around
as turning "default" into a class — especially because I don't want a
define, I want a class with a tiny bit of configuration.[1]

Still, it is probably less bad than the alternatives, and I do agree that
using a define (or, next release, a parametrized class) is a better solution
than action-at-a-distance variables.

        Daniel

Footnotes: 
[1]  In this case, one bit worth of configuration, dammit.

-- 
✣ Daniel Pittman            ✉ dan...@rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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