Skip to content

Instantly share code, notes, and snippets.

@jedi4ever
Created June 11, 2012 15:43
Show Gist options
  • Save jedi4ever/2910754 to your computer and use it in GitHub Desktop.
Save jedi4ever/2910754 to your computer and use it in GitHub Desktop.
hiera defines musings
define mymodule::party( $param1 , $param2
) {
}
With Hiera I can do
define mymodule::party( $param1 = hiera('param1','somedefault1') , $param2 = hiera('param2','somedefault2')
) {
}
But I'd like to have the default come from my data.pp/params.pp file per module
Would the hiera backend :puppet take care of this?
define logstash::agent(
$osUser = undef ,
$version = undef ,
$installDir = undef ,
$downloadUrl = undef ,
$javaHome = undef ,
$javaMx = undef ,
$config = undef
) {
# Load defaults from params (and possibly hiera)
include logstash::data
# some day we'll replace it with
# defaultify('real_','data',['osUser','version','...'])
# Alternative1: use data.pp with puppet data in hiera - makes the module dependent on hiera config
# Alternative2: use $osUser = hiera(... in vars, means we can't put module config in a central place
if $osUser == undef { $real_osUser = $logstash::data::osUser } else { $real_osUser = $osUser }
if $version == undef { $real_version = $logstash::data::version } else { $real_javaMx = $javaMx }
if $installDir == undef { $real_installDir = $logstash::data::installDir } else { $real_installDir = $installDir }
if $downloadUrl == undef { $real_downloadUrl = $logstash::data::downloadUrl } else { $real_downloadUrl = $downloadUrl }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment