sender.pp 1015 Bytes
Newer Older
Karl Kornel's avatar
Karl Kornel committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Many systems send emails "From" root@system-name.  That causes problems when
# an email is bounced.  This type is used to have Postfix change the sender
# address of an email while it is in flight.  Both the From: header and the
# envelope sender are changed.
#
# Example of how to set a sender:
#
#     base::postfix::sender { 'root@stanford.edu':
#       ensure => 'noreply@stanford.edu'
#     }
#
# Example of how to ensure there is no sender map:
#
#     base::postfix::sender { 'luke': ensure => absent }
#
# Assumes that a command 'postmap hash:$file' has been defined that will
# rebuild the senders map.

define base::postfix::sender(
  $ensure,
  $file = '/etc/postfix/senders'
) {
23
24
25
26
27
28
29
30
31
32
33
34
35
  $line = "${name} ${ensure}"
  $file_line_ensure = $ensure ? {
    'absent' => 'absent',
    default  => 'present',
  }

  file_line { "add-sender-${name}":
    ensure  => $file_line_ensure,
    path    => $file,
    line    => $line,
    require => Package['postfix'],
    notify  => Exec["postmap hash:${file}"],
  }
Karl Kornel's avatar
Karl Kornel committed
36
}