Defined Type: dovecot::extconfigfile

Defined in:
manifests/extconfigfile.pp

Summary

Resource for external config files providing a very basic key-value interface.

Overview

Parameters:

  • additional_content (Optional[String]) (defaults to: undef)

    Additional content for the file.

  • entries (Hash[String, String])

    A hash of string=string entries. All values will be written as-is to the file, any escaping must already be applied.

  • group (Variant[Integer, String]) (defaults to: 0)

    The group that should own the file.

  • mode (Variant[Integer, String]) (defaults to: $dovecot::extconfigs_mode)

    The permissions for the file.

  • owner (Variant[Integer, String]) (defaults to: 'root')

    The user that should own the file.

  • relpath (String) (defaults to: $title)

    The path of the external config file relative to dovecot::config_path, including the desired extension. Defaults to the resource title.

  • warn (Variant[Boolean, String]) (defaults to: true)

    Whether to prepend the default warning (if ‘true`), a custom warning (if a `String`), or nothing at all.

Author:

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



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'manifests/extconfigfile.pp', line 31

define dovecot::extconfigfile (
  Hash[String, String] $entries,
  Optional[String] $additional_content = undef,
  String $relpath = $title,
  Variant[Boolean, String] $warn = true,
  Variant[Integer, String] $group = 0,
  Variant[Integer, String] $mode = $dovecot::extconfigs_mode,
  Variant[Integer, String] $owner = 'root',
) {
  $_header = $warn ? {
    true    => "# This file is managed by Puppet. DO NOT EDIT.\n\n",
    String  => "${warn}\n",
    default => '',
  }

  $_entries = String($entries, {
      Hash => {
        format => '% h',
        separator => "\n",
        separator2 => ' = ',
        string_formats => { Any => '%s' },
      }
  })

  if $additional_content {
    $_additional_content = "${additional_content}\n"
  } else {
    $_additional_content = ''
  }

  $_content = "${_header}${_entries}\n${additional_content}"

  file { "dovecot external config file ${title}":
    path    => "${dovecot::config_path}/${relpath}",
    owner   => $owner,
    group   => $group,
    mode    => $mode,
    content => $_content,
    require => Class['dovecot::install'],
    notify  => Class['dovecot::service'],
  }
}