-
-
Notifications
You must be signed in to change notification settings - Fork 176
/
mta.pp
60 lines (53 loc) · 2.25 KB
/
mta.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# @summary Configures Postfix as minimal MTA
#
# @api private
#
class postfix::mta (
Optional[Pattern[/^\S+(?:,\s*\S+)*$/]] $mydestination = undef,
Optional[Pattern[/^(?:\S+?(?:(?:,\s+)|(?:\s+))?)*$/]] $mynetworks = undef,
Optional[Pattern[/^\S+$/]] $relayhost = undef,
Optional[Array[String[1]]] $masquerade_classes = undef,
Optional[Array[String[1]]] $masquerade_domains = undef,
Optional[Array[String[1]]] $masquerade_exceptions = undef,
) {
assert_private()
include postfix
$_mydestination = pick($mydestination, $postfix::mydestination)
$_mynetworks = pick($mynetworks, $postfix::mynetworks)
$_relayhost = pick($relayhost, $postfix::relayhost)
$_masquerade_classes = $masquerade_classes.lest || { $postfix::masquerade_classes }
$_masquerade_domains = $masquerade_domains.lest || { $postfix::masquerade_domains }
$_masquerade_exceptions = $masquerade_exceptions.lest || { $postfix::masquerade_exceptions }
# If direct is specified then relayhost should be blank
if ($_relayhost == 'direct') {
postfix::config { 'relayhost': ensure => 'blank' }
}
else {
postfix::config { 'relayhost': value => $_relayhost }
}
if ($_mydestination == 'blank') {
postfix::config { 'mydestination': ensure => 'blank' }
} else {
postfix::config { 'mydestination': value => $_mydestination }
}
postfix::config {
'mynetworks': value => $_mynetworks;
'virtual_alias_maps': value => "${postfix::lookup_table_type}:${postfix::confdir}/virtual";
'transport_maps': value => "${postfix::lookup_table_type}:${postfix::confdir}/transport";
}
if ! $_masquerade_classes.empty() {
postfix::config { 'masquerade_classes': value => join($_masquerade_classes, ' ') }
}
if ! $_masquerade_domains.empty() {
postfix::config { 'masquerade_domains': value => join($_masquerade_domains, ' ') }
}
if ! $_masquerade_exceptions.empty() {
postfix::config { 'masquerade_exceptions': value => join($_masquerade_exceptions, ' ') }
}
postfix::hash { "${postfix::confdir}/virtual":
ensure => 'present',
}
postfix::hash { "${postfix::confdir}/transport":
ensure => 'present',
}
}