We're using the roles/profiles pattern. In the example below I'd like to optionally pass a parameter from hiera so that if no value is provided then the ::apache class default is used (which it gets internally from its ::apache::params class). This would enable us to set the keepalive value on some servers but allow the ::apache class to determine the value itself when we don't.
common.yaml
-----------
profiles::apache::keepalive : On
profiles::apache::keepalive_timeout : 5
apache.pp
---------
class profiles::apache {
$apache_keepalive = hiera('profiles::apache::keepalive')
$apache_keepalive_timeout = hiera('profiles::apache::keepalive_timeout')
class {'::apache':
keepalive => $apache_keepalive,
keepalive_timeout => $apache_keepalive_timeout,
}
}
I've tried setting the default value of the hiera lookup to 'undef' but then I end up with empty values in the config.
Best Answer
You achieve this effect through automatic parameter lookup.
Your Hiera data targets the actual apache module, not your apache profile.
This only works if
class apache
has a$keepalive
parameter.And yes, the default for this should be taken from
apache::params
.