mta.pp 1.78 KB
Newer Older
1
2
#
# == Class: postfix::mta
3
4
#
# This class configures a minimal MTA, listening on
5
# $postfix_smtp_listen (default to localhost) and delivering mail to
6
7
8
9
10
# $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
# Parameters:
# - *$postfix_relayhost*
# - *$postfix_mydestination*
16
# - every global variable which works for class 'postfix' will work here.
17
18
#
# Example usage:
19
#
20
21
22
#   node 'toto.example.com' {
#     $postfix_relayhost = 'mail.example.com'
#     $postfix_smtp_listen = '0.0.0.0'
23
#     $postfix_mydestination = '$myorigin, myapp.example.com'
24
#
25
#     include postfix::mta
26
#
27
#     postfix::transport { 'myapp.example.com':
28
#       ensure => present,
29
#       destination => 'local:',
30
#     }
31
32
#   }
#
Francois Deppierraz's avatar
Francois Deppierraz committed
33
class postfix::mta {
34

35
36
37
38
39
  $mydestination = $postfix::mydestination ? {
    undef   => $postfix::myorigin,
    default => $postfix::mydestination,
  }

40
41
  validate_re($postfix::relayhost, '^\S+$',
              'You must pass $relayhost to the postfix class')
42
  validate_re($mydestination, '^\S+$',
43
44
45
              'You must pass $mydestination to the postfix class')
  validate_re($postfix::mynetworks, '^\S+$',
              'You must pass $mynetworks to the postfix class')
46

Francois Deppierraz's avatar
Francois Deppierraz committed
47
  postfix::config {
48
    'mydestination':       value => $mydestination;
49
50
    'mynetworks':          value => $postfix::mynetworks;
    'relayhost':           value => $postfix::relayhost;
51
52
    'virtual_alias_maps':  value => 'hash:/etc/postfix/virtual';
    'transport_maps':      value => 'hash:/etc/postfix/transport';
53
54
  }

55
  postfix::hash { '/etc/postfix/virtual':
56
57
58
    ensure => present,
  }

59
  postfix::hash { '/etc/postfix/transport':
60
61
62
63
    ensure => present,
  }

}