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

dovecot::create_config_resources(Hash[String, NotUndef] $config_hash, Hash $params = {}, Array[String] $sections = [])Any

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.

Parameters:

  • config_hash (Hash[String, NotUndef])

    a hash of (non-hierarchical) key names mapped to values

  • params (Hash) (defaults to: {})

    a hash of params passed to dovecot::config (must not include :sections, :key, or :value)

  • sections (Array[String]) (defaults to: [])

    the section names of the hierarchical key, will usually only be specified on recursive calls from within this function itself

Returns:

  • (Any)

See Also:

Author:

  • Bernhard Frauendienst <puppet@nospam.obeliks.de>



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,
        }
      }
    }
  }
}