Puppet Class: postfix::config

Inherits:
postfix
Defined in:
manifests/config.pp

Overview

This class handles postfix configuration. Avoid modifying private classes.



3
4
5
6
7
8
9
10
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'manifests/config.pp', line 3

class postfix::config inherits postfix {
  each({
    'postconf' => $postfix::purge_main,
    'postconf_master' => $postfix::purge_master,
  }) |$res, $purge| {
    case $purge {
      true, 'true', 'noop': { # lint:ignore:quoted_booleans
        resources { $res: purge => true, noop => $purge == 'noop' }
      }
      false, 'false': {} # lint:ignore:quoted_booleans
      default: {
        fail("Illegal value for purge: ${purge}")
      }
    }
  }

  $postfix::main_config.each |$key, $value| {
    $_value = $value ? {
      true    => 'yes',
      false   => 'no',
      default => $value,
    }
    postconf { $key: value => $_value }
  }
  $postfix::master_services.each |$key, $args| {
    $_args = delete($args, [command, options])
    if $args[options] {
      $_command = $args[options].reduce($args[command]) |$c, $o| {
        $key = $o[0]
        $val = $o[1]
        $_val = $val ? {
          true    => 'yes',
          false   => 'no',
          default => $val,
        }
        $opt = $_val ? {
          / /     => "-o { ${key} = ${_val} }",
          default => "-o ${key}=${_val}",
        }
        "${c} ${opt}"
      }
    } else {
      $_command = $args[command]
    }
    postconf_master { $key:
      command => $_command,
      *       => $_args,
    }
  }
}