postfix-mta.pp 1.64 KB
Newer Older
1
2
#
# == Class: postfix::mta
3
4
5
6
7
8
9
10
#
# This class configures a minimal MTA, listening on
# $postfix_ng_smtp_listen (default to localhost) and delivering mail to
# $postfix_mydestination (default to $fqdn).
#
# A valid relay host is required ($postfix_relayhost) for outbound email.
#
# transport & virtual maps get configured and can be populated with
Francois Deppierraz's avatar
Francois Deppierraz committed
11
# postfix::transport and postfix::virtual
12
#
13
14
15
16
17
18
# Parameters:
# - *$postfix_relayhost*
# - *$postfix_mydestination*
# - every global variable which works for class "postfix" will work here.
#
# Example usage:
19
#
20
21
22
23
#   node "toto.example.com" {
#     $postfix_relayhost = "mail.example.com"
#     $postfix_ng_smtp_listen = "0.0.0.0"
#     $postfix_mydestination = "\$myorigin, myapp.example.com"
24
#
25
#     include postfix::mta
26
#
27
28
29
30
#     postfix::transport { "myapp.example.com":
#       ensure => present,
#       destination => "local:",
#     }
31
32
#   }
#
Francois Deppierraz's avatar
Francois Deppierraz committed
33
class postfix::mta {
34
35
36
37
38
39
40
41
42

  case $postfix_relayhost {
    "":   { fail("Required \$postfix_relayhost variable is not defined.") }
  }

  case $postfix_mydestination {
    "": { $postfix_mydestination = "\$myorigin" }
  }

Francois Deppierraz's avatar
Francois Deppierraz committed
43
  include postfix
44

Francois Deppierraz's avatar
Francois Deppierraz committed
45
  postfix::config {
46
47
48
49
50
51
52
    "mydestination":                        value => $postfix_mydestination;
    "mynetworks":                           value => "127.0.0.0/8";
    "relayhost":                            value => $postfix_relayhost;
    "virtual_alias_maps":                   value => "hash:/etc/postfix/virtual";
    "transport_maps":                       value => "hash:/etc/postfix/transport";
  }

Francois Deppierraz's avatar
Francois Deppierraz committed
53
  postfix::hash { "/etc/postfix/virtual":
54
55
56
    ensure => present,
  }

Francois Deppierraz's avatar
Francois Deppierraz committed
57
  postfix::hash { "/etc/postfix/transport":
58
59
60
61
    ensure => present,
  }

}