mta.pp 1.83 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
  $mydestination = $postfix::mydestination ? {
36
    undef   => '$myorigin',
37
38
39
    default => $postfix::mydestination,
  }

40
  $mynetworks = $postfix::mynetworks ? {
41
    undef   => '127.0.0.0/8',
42
43
44
    default => $postfix::mynetworks,
  }

45
46
  validate_re($postfix::relayhost, '^\S+$',
              'You must pass $relayhost to the postfix class')
47
  validate_re($mydestination, '^\S+$',
48
49
50
              'Wrong value for $mydestination')
  validate_re($mynetworks, '^\S+$',
              'Wrong value for $mynetworks')
51

Francois Deppierraz's avatar
Francois Deppierraz committed
52
  postfix::config {
53
    'mydestination':       value => $mydestination;
54
    'mynetworks':          value => $mynetworks;
55
    'relayhost':           value => $postfix::relayhost;
56
57
    'virtual_alias_maps':  value => 'hash:/etc/postfix/virtual';
    'transport_maps':      value => 'hash:/etc/postfix/transport';
58
59
  }

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

64
  postfix::hash { '/etc/postfix/transport':
65
66
67
68
    ensure => present,
  }

}