Ask Your Question

use hiera to set default class parameters in the module - but don't make them changeable in each hiera file

asked 2018-01-19 15:38:28 -0600

heiner gravatar image

I like the idea to set class parameter defaults in a hiera yaml file included in the module. But this allows users to change the class defaults from using any yaml file in the hierarchy. I don't want to expose the default values. I want to use a role/profile pattern and expose a much smaller set of parameters to the 'user'. The 'user' being able to change parameter defaults values circumvents the encapsulation promised by the role/profile pattern.

I don't want to set all class parameters in each profile declaring a certain class. If there is a good default value it should be set just once.

This is puzzling me quiet a bit. I would welcome any replies or comments. How do you handle this? Just by rule/convention, like only parameters named profile::... are allowed to set in hiera outside the module?


edit retag flag offensive close merge delete


Huh, I can't grasp your problem. The whole point of providing default values for class parameters _is_, that the class _is_ _usable_ without a user providing any values to it, but is customizable to the user's needs. If you don't want that, don't provide the interface via defining a class parameter.

Kai Burghardt gravatar imageKai Burghardt ( 2018-01-20 11:11:03 -0600 )edit

Kai, I want to make use of default values but I don't want them to be changeable outside of the module's code. Still it would be very helpful to put them all in one yaml file per module (or more, if needed).

heiner gravatar imageheiner ( 2018-01-21 17:28:18 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-02-04 04:23:37 -0600

Henrik Lindberg gravatar image

You cannot do that as suggested - simply because the feature that is designed to conveniently compose and override default values cannot be made to not allow that.

If something is not supposed to be seen or used or overridden then it should be considered private to your module. If you have something where some of the things should be seen (like the name of a class), but not other things (like parameters and default values), then you need to separate the logic into a public part (no parameters), and a private (where you set the parameters).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2018-01-19 15:32:48 -0600

Seen: 52 times

Last updated: Feb 04