Try to make the manualroute on the mailrelays using a store/collect pattern
authorPeter Palfrader <peter@palfrader.org>
Sat, 21 Sep 2019 21:56:08 +0000 (23:56 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sat, 21 Sep 2019 21:56:08 +0000 (23:56 +0200)
modules/exim/manifests/mailrelay.pp
modules/roles/manifests/mta.pp

index f0feedb..09afd67 100644 (file)
@@ -10,4 +10,14 @@ class exim::mailrelay {
       @hourly  root if [ ! -d /etc/exim4/email-virtualdomains ]; then cd /etc/exim4 && git clone mail-git:email-virtualdomains ; fi && cd /etc/exim4/email-virtualdomains && git pull --quiet --ff-only
       | EOF
   }
+
+
+  concat { '/etc/exim4/manualroute-new':
+    mode           => '0444',
+    ensure_newline => true,
+    warn           => '# This file is maintained with puppet',
+    require        => Package['exim4-daemon-heavy']
+  }
+
+  Concat::Fragment <<| tag == 'exim::manualroute::to::mailrelay' |>>
 }
index 3ce4443..4e672d7 100644 (file)
@@ -15,6 +15,20 @@ class roles::mta(
       include exim::mx
     } else {
       include exim
+
+      $mxdata = dig($deprecated::nodeinfo, 'ldap', 'mxRecord')
+      if $mxdata and $mxdata =~ /INCOMING-MX/ {
+        $mailport = lookup('exim::mail_port')
+
+        @@concat::fragment { "manualroute-to-${::fqdn}":
+          tag     => 'exim::manualroute::to::mailrelay',
+          target  => '/etc/exim4/manualroute-new',
+          content => $mailport == undef ? {
+            true    => "${::fqdn}:   ${::fqdn}",
+            default => "${::fqdn}:   ${::fqdn}::${mailport}",
+          }
+        }
+      }
     }
   } elsif $type == 'postfix' {
     if $mailrelay {