On Tuesday, May 29, 2018 at 1:04:10 PM UTC-5, Ugo Bellavance wrote:
>
> That's awfully surprising if those data appear in an Hiera data file from
>> which you are successfully loading other data. If that is in fact
>> happening then the most likely reason would be that a resource-like class
>> declaration for that class somewhere in your manifest set is explicitly
>> declaring different parameter values for that class (in which case the
>> Hiera data will not be consulted). But if that were the case, then I would
>> expect Puppet to raise an error when you added your own resource-like
>> declaration of the same class. Another possibility is that there are
>> conflicting data in some higher-priority level of your data hierarchy, but
>> that would be surprising considering how you arrived where you now are.
>>
>> My best guess, therefore, is that the file in which you placed the
>> parameter data is not being consulted at all for the node in question (so
>> that in fact you are *not* successfully loading other data from it,
>> either).
>>
>>
> I'm testing with a minimal setup, just to make sure.
>
> I have one manifest, site.pp, that I call locally (no server), and one
> hiera file, common.yaml.
>
> I found it. I stupidly commented the whole class declaration in site.pp.
>
> When I leave just the class declaration it works:
>
> class {'postgresql::server::contrib':
> }
>
Well if that serves your needs (and it should) then it is better form to
use an include-like declaration instead:
include 'postgresql::server::contrib'
But that's mostly a style consideration. It will affect behavior only if
now or in the future there is a(nother) resource-like declaration of that
class somewhere in your manifest set.
Is there a way to have the class declaration in hiera? I tried using this
> at the top of my yaml file but it didn't work:
>
> ---
> classes:
> - postgresql::server::contrib
>
Hiera just provides data and metadata. It does not have any inherent
behavior associated.
But that absolutely can have the form of an array of class names, which can
even be spread across multiple hierarchy levels, and you can use that array
to declare the named classes. The old way was to use the hiera_include()
function in one of your manifests, but in recent Puppet (4.x and later) you
should be using the lookup() function and regular include() function:
include(lookup('classes', Array[String], 'unique', []))
>
>
>>
>>
>>> So class parameters are automatically looked up in hiera, but define
>>> parameters (or whatever name it is for objects) is not?
>>>
>>
>>
>> That is correct. There are good reasons for it, but a discussion of
>> those would be tangential. If you're interested, you can find at least one
>> such discussion in the archives of this group.
>>
>>
> Ok thanks,
>
> Are the modules supposed to manage that or the user?
>
Whoever declares a resource instance or a class is responsible for binding
the appropriate values to its parameters. In particular, modules are
responsible for binding appropriate data to the resources and classes that
they declare internally, but you are responsible for binding values to the
resources and classes that you declare, regardless of where the class or
resource type is *defined*, and, for resources, regardless of whether they
are of plug-in or defined type. If one interprets "the user" as "whoever
is responsible for the declaration" on an entity-by-entity basis, then that
simplifies to the user being responsible for managing parameters.
Of course, where a resource type or class defines default values for its
parameters and those values meet your requirements, it's fine to rely on
those. You don't necessarily need to explicitly provide a value for every
parameter. And do note the important distinction between *declaring* a
class or resource, and *defining* a class or resource type.
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/8d10401a-6703-4d7a-b003-aa82350b7b3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.