Puppet Function: openldap::flatten_syncrepl

Defined in:
functions/flatten_syncrepl.pp
Function type:
Puppet Language

Overview

openldap::flatten_syncrepl(Optional[Array[OpenLDAP::Syncrepl, 1]] $values)Optional[Array[String, 1]]

Flatten an array of syncrepl directives to an array of strings.

Examples:

openldap::flatten_syncrepl([{'rid' => 1, 'provider' => 'ldap://ldap.example.com', 'searchbase' => 'dc=example,dc=com'}])

Parameters:

  • values (Optional[Array[OpenLDAP::Syncrepl, 1]])

    The array of directives to flatten, undef is passed through.

Returns:

  • (Optional[Array[String, 1]])

    The array of flattened directives.

Since:

  • 2.0.0



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'functions/flatten_syncrepl.pp', line 11

function openldap::flatten_syncrepl(Optional[Array[OpenLDAP::Syncrepl, 1]] $values) {

  $values ? {
    undef   => undef,
    default => $values.map |OpenLDAP::Syncrepl $s| {
      join([sprintf('rid=%03d', $s['rid'])] + $s.filter |$x| {
        $x[0] != 'rid'
      }.map |$x| {
        case $x[0] {
          'binddn', 'logbase', 'logfilter', 'searchbase': {
            "${x[0]}=\"${x[1]}\""
          }
          'retry': {
            "${x[0]}=\"${join(flatten($x[1]), ' ')}\""
          }
          'schemachecking': {
            "${x[0]}=${bool2str($x[1], 'on', 'off')}"
          }
          default: {
            "${x[0]}=${x[1]}"
          }
        }
      }, ' ')
    },
  }
}