Puppet Function: dovecot::create_config_resources
- Defined in:
- functions/create_config_resources.pp
- Function type:
- Puppet Language
Summary
create dovecot::config resources from a nested hash (e.g. from hiera)Overview
Create dovecot::config resources from a nested hash, suitable for conveniently loading values from hiera. The key-value pairs from the hash represent config keys and values passed to dovecot::config for simple values, Hash values recursively create nested sections, and Array values are joined with spaces.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'functions/create_config_resources.pp', line 19
function dovecot::create_config_resources(Hash[String, NotUndef] $config_hash, Hash $params = {}, Array[String] $sections = []) {
$config_hash.each |$key, $value| {
case $value {
Hash: {
dovecot::create_config_resources($value, $params, $sections + $key)
}
Array: {
# be lazy and delegate to ourself. Non-string values will be stringified without mercy!
dovecot::create_config_resources({ $key => join($value, ' ') }, $params, $sections)
}
default: {
dovecot::config { "${params[file]}:${join($sections + $key, '.')}":
sections => $sections,
key => $key,
value => $value,
* => $params,
}
}
}
}
}
|