config.pp 1.31 KB
Newer Older
1
2
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
/*
== Definition: postfix::config

Uses the "postconf" command to add/alter/remove options in postfix main
configuation file (/etc/postfix/main.cf).

Parameters:
- *name*: name of the parameter.
- *ensure*: present/absent. defaults to present.
- *value*: value of the parameter.
- *nonstandard*: inform postfix::config that this parameter is not recognized
  by the "postconf" command. defaults to false.

Requires:
- Class["postfix"]

Example usage:

  node "toto.example.com" {

    include postfix

    postfix::config {
      "smtp_use_tls"            => "yes";
      "smtp_sasl_auth_enable"   => "yes";
      "smtp_sasl_password_maps" => "hash:/etc/postfix/my_sasl_passwords";
      "relayhost"               => "[mail.example.com]:587";
    }
  }

*/
Francois Deppierraz's avatar
Francois Deppierraz committed
32
define postfix::config ($ensure = present, $value, $nonstandard = false) {
33
34
35
36
37
38
39
40
41
42
43
44
45
  case $ensure {
    present: {
      exec {"postconf -e ${name}='${value}'":
        unless  => $nonstandard ? {
          false => "test \"x$(postconf -h ${name})\" == 'x${value}'",
          true  => "test \"x$(egrep '^${name} ' /etc/postfix/main.cf | cut -d= -f2 | cut -d' ' -f2)\" == 'x${value}'",
        },
        notify  => Service["postfix"],
        require => File["/etc/postfix/main.cf"],
      }
    }

    absent: {
Francois Deppierraz's avatar
Francois Deppierraz committed
46
      fail "postfix::config ensure => absent: Not implemented"
47
48
49
    }
  }
}