mxRecord is actually an array called mXRecord
[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     } elsif $heavy {
15       include exim::mx
16     } else {
17       include exim
18
19       $mxdata = dig($deprecated::nodeinfo, 'ldap', 'mXRecord')
20       if $mxdata and $mxdata.any |$item| { $item =~ /INCOMING-MX/ } {
21         $mailport = lookup('exim::mail_port')
22
23         @@concat::fragment { "manualroute-to-${::fqdn}":
24           tag     => 'exim::manualroute::to::mailrelay',
25           target  => '/etc/exim4/manualroute-new',
26           content => $mailport == undef ? {
27             true    => "${::fqdn}:   ${::fqdn}",
28             default => "${::fqdn}:   ${::fqdn}::${mailport}",
29           }
30         }
31       }
32     }
33   } elsif $type == 'postfix' {
34     if $mailrelay {
35       fail("Unsupported: mailrelay on type ${type}")
36     }
37     include postfix
38   } else {
39     fail("Unexpected mta type ${type}")
40   }
41 }