Even heavy_exim hosts can get their system mail from relays
[mirror/dsa-puppet.git] / modules / roles / manifests / mta.pp
1 # Every one of our hosts has an MTA
2 #
3 # @param type exim4 or postfix.  exim4 is our default MTA
4 # @param heavy receive email from the internet and thus do spam filtering etc
5 # @param mailrelay receive mail on other hosts' behalf.  implies heavy
6 class roles::mta(
7   Enum['exim4', 'postfix'] $type = 'exim4',
8   Boolean $heavy = false,
9   Boolean $mailrelay = false,
10 ) {
11   if $type == 'exim4' {
12     if $mailrelay {
13       include roles::mailrelay
14     } else {
15       if $heavy {
16         include exim::mx
17       } else {
18         include exim
19       }
20
21       $mxdata = dig($deprecated::nodeinfo, 'ldap', 'mXRecord')
22       if $mxdata and $mxdata.any |$item| { $item =~ /INCOMING-MX/ } {
23         $mailport = lookup( { 'name' => 'exim::mail_port', 'default_value' => undef } )
24
25
26         @@concat::fragment { "manualroute-to-${::fqdn}":
27           tag     => 'exim::manualroute::to::mailrelay',
28           target  => '/etc/exim4/manualroute-new',
29           content => $mailport == undef ? {
30             true    => "${::fqdn}:   ${::fqdn}",
31             default => "${::fqdn}:   ${::fqdn}::${mailport}",
32           }
33         }
34       }
35     }
36   } elsif $type == 'postfix' {
37     if $mailrelay {
38       fail("Unsupported: mailrelay on type ${type}")
39     }
40     include postfix
41   } else {
42     fail("Unexpected mta type ${type}")
43   }
44 }