> On Fri, Sep 7, 2012 at 9:10 AM, R.I.Pienaar <
r...@devco.net> wrote:
> >
> > but what if you had something like this:
> >
> > class example::data {
> > case $::ofamily {
> > "RedHat": { $service = "httpd" }
> > "Debian": { $service = "apache2" }
> > default: { fail("Please specify a service name using hiera")
> > }
> > }
> > }
> >
> > Here we clearly model different behaviours depending on the context
> > and
> > clearly state what we do not support via default but still alow the
> > module user to then decide they would provide this override data
> > through whatever hierarchy make sense for their site, ENC or just
> > hardcoding it.
> >
>
> The data bindings can handle that by having the Debian and Redhat
> cases in hiera (all of the facts are available to the data binding
> service) and then the class would have:
>
> class example($service = "UNKNOWN") {
> if ($service == "UNKNOWN") {
> fail("Please specify a service name")
> }
> }
>
> I don't think this is quite as clear as the data class form, since
> there is now no single place to look to understand the behavior.
this assumes everyone has operating system hierarchies, the data class
example specifically makes the class multi os aware regardless of whatever
hierarchies users have provided.
In your example you'd either need to have a similar case in the example
class - thus coupling the data processing into the logic class - or
force everyone to have OS hierarchies AND supplying all the data you
need.
The point of a in-puppet hierarchy is that it's there by default and
works by default as a last resort in the case that a user doesn't provide
the data.
It's also a good crutch in the case where people want to do crazy logic
on their data using complex if/case/math which they couldn't do using the
yaml/json/whatever data sources as those clearly can't contain any kind
of logic other than that provided by the fact based selection which is
roughly equivalent to a case statement
consider:
class exim::data {
$deliver_queue_load_max = $cpu_cores * 1.2
}
Here we want exim to not deliver mail when the server is too loaded
but what defines 'too loaded' depends on the amount of cores the machine
has. It would be pretty painful to express this in pure-data hiera
as you'd need to dedicate an entire hierarchy to the amount of cores
present, quite a pain
I'd think the only sane alternative is:
class example($service=$example::data::service) {...}
which roughly achieves the same as the hiera-puppet backend in this
specific example, not particularly nice though I'd think we can do
better
OK