--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/61c18a0f-76fe-4be8-83fc-aa8703f28cb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/93053ac8-a9ba-46e8-a6b7-e46fa150fad8%40googlegroups.com.
Hi,
postgresql::server::contrib::package_name: 'rh-postgresql96-postgresql-contrib'
postgresql::server::contrib::packages_ensure: present
On Tuesday, May 29, 2018 at 5:54:54 AM UTC-4, Arnau wrote:Hi,postgresql::server::contrib::package_name: 'rh-postgresql96-postgresql-contrib'
postgresql::server::contrib::packages_ensure: present
I don't get the error anymore. It's not doing what it's supposed but I'll look into it. I'll try the same thing with the manifest just to see.
But why do we have to use create_resources for the postgresql::server::db section but all the others are OK? Is it just because
postgresql::server::db is an array?
create_resourcesConverts a hash into a set of resources and adds them to the catalog.This function takes two mandatory arguments: a resource type, and a hash describing a set of resources. The hash should be in the form {title => {parameters} }:
class postgresql::server::contrib (String $package_name = $postgresql::params::contrib_package_name,String[1] $package_ensure = 'present') inherits postgresql::params {
--
Thanks,
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/d796f5ff-311a-46a0-b703-f12d7f1555b7%40googlegroups.com.
2018-05-29 12:24 GMT+02:00 Ugo Bellavance <ug...@lubik.ca>:
On Tuesday, May 29, 2018 at 5:54:54 AM UTC-4, Arnau wrote:Hi,postgresql::server::contrib::package_name: 'rh-postgresql96-postgresql-contrib'
postgresql::server::contrib::packages_ensure: present
I don't get the error anymore. It's not doing what it's supposed but I'll look into it. I'll try the same thing with the manifest just to see.What is it doing ?
What vesion of pupet/hiera? what version of the postgres module are you using?
But why do we have to use create_resources for the postgresql::server::db section but all the others are OK? Is it just because
postgresql::server::db is an array?create_resourcesConverts a hash into a set of resources and adds them to the catalog.This function takes two mandatory arguments: a resource type, and a hash describing a set of resources. The hash should be in the form {title => {parameters} }:postgresql::server::db is a define
postgresql::server::contrib is a class
In the first case you use create_resources cause you want to create resources from the type postgresql::server::db (one or many). So the create_resources function expects a hash with a list of databases + its parameters.
The second case you want to pass values to a class parameters. The class does not expect any has:class postgresql::server::contrib (String $package_name = $postgresql::params::contrib_package_name,String[1] $package_ensure = 'present') inherits postgresql::params {
On Tuesday, May 29, 2018 at 6:55:01 AM UTC-4, Arnau wrote:2018-05-29 12:24 GMT+02:00 Ugo Bellavance <ug...@lubik.ca>:
On Tuesday, May 29, 2018 at 5:54:54 AM UTC-4, Arnau wrote:Hi,postgresql::server::contrib::package_name: 'rh-postgresql96-postgresql-contrib'
postgresql::server::contrib::packages_ensure: present
I don't get the error anymore. It's not doing what it's supposed but I'll look into it. I'll try the same thing with the manifest just to see.What is it doing ?It should be install the package with the name specified in postgresql::server::contrib::package_nameSetting the parameters in the manifest works:class {'postgresql::server::contrib':package_name => 'rh-postgresql96-postgresql-contrib',package_ensure => 'present',}But this hiera data doesn't:postgresql::server::contrib::package_name: 'rh-postgresql96-postgresql-contrib'postgresql::server::contrib::packages_ensure: present
So class parameters are automatically looked up in hiera, but define parameters (or whatever name it is for objects) is not?
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).
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.
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':}
include 'postgresql::server::contrib'
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
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?
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::contribHiera 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
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.
This is something that I have always had trouble understanding and lacked time to read more on it. And even if I read on it...
# Class definition
class mymodule::myclass (String $a_param) {
notify { "${a_param}": }
}
# (Defined) type definition
define mymodule::mytype (String $a_param) {
notify { "${title}: ${a_param}": }
}
# A resource-like class declaration
class { 'mymodule::myclass': a_param => 'value' }
# Various include-like class declarations:
include 'mymodule::myclass'
require 'mymodule::myclass'
contain 'mymodule::myclass'
# A resource declaration
mymodule::mytype { 'title': a_param => 'value' }
# A function call that causes a resource to be declared
create_resources('mymodule::mytype', { 'title2' => { 'a_param' => 'value2' } })