mta.pp 1.73 KB
Newer Older
1
# == Class: postfix::mta
2
#
Raphaël Pinson's avatar
Doc    
Raphaël Pinson committed
3
4
# This class configures a minimal MTA, delivering mail to
# $mydestination.
5
#
6
# Either a valid relay host or the special word 'direct' is required
7
# ($relayhost) for outbound email.
8
9
#
# transport & virtual maps get configured and can be populated with
Francois Deppierraz's avatar
Francois Deppierraz committed
10
# postfix::transport and postfix::virtual
11
#
Raphaël Pinson's avatar
Doc    
Raphaël Pinson committed
12
# === Parameters
13
#
14
15
# [*relayhost*]     - (string) the relayhost to use or 'direct' to send mail
#                     directly without a relay.
Raphaël Pinson's avatar
Doc    
Raphaël Pinson committed
16
17
# [*mydestination*] - (string)
# [*mynetworks*]    - (string)
18
#
Raphaël Pinson's avatar
Doc    
Raphaël Pinson committed
19
# === Examples
20
#
Raphaël Pinson's avatar
Doc    
Raphaël Pinson committed
21
22
23
24
25
#   class { 'postfix':
#     relayhost     => 'mail.example.com',
#     smtp_listen   => '0.0.0.0',
#     mydestination => '$myorigin, myapp.example.com',
#     mta           => true,
26
27
#   }
#
28
class postfix::mta (
29
30
31
  Pattern[/^\S+(?:,\s*\S+)*$/]                 $mydestination = $postfix::mydestination,
  Pattern[/^(?:\S+?(?:(?:,\s+)|(?:\s+))?)*$/]  $mynetworks    = $postfix::mynetworks,
  Pattern[/^\S+$/]                             $relayhost     = $postfix::relayhost,
32
) {
33

34
35
36
37
38
39
40
41
  # If direct is specified then relayhost should be blank
  if ($relayhost == 'direct') {
    postfix::config { 'relayhost': ensure => 'blank' }
  }
  else {
    postfix::config { 'relayhost': value => $relayhost }
  }

42
43
44
45
46
47
  if ($mydestination == 'blank') {
    postfix::config { 'mydestination': ensure => 'blank' }
  } else {
    postfix::config { 'mydestination': value => $mydestination }
  }

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

54
  postfix::hash { '/etc/postfix/virtual':
Raphaël Pinson's avatar
Raphaël Pinson committed
55
    ensure => 'present',
56
57
  }

58
  postfix::hash { '/etc/postfix/transport':
Raphaël Pinson's avatar
Raphaël Pinson committed
59
    ensure => 'present',
60
61
62
  }

}