move exim vs. postfix, heavy vs. not, into hiera
authorPeter Palfrader <peter@palfrader.org>
Sat, 21 Sep 2019 16:40:18 +0000 (18:40 +0200)
committerPeter Palfrader <peter@palfrader.org>
Sat, 21 Sep 2019 17:01:04 +0000 (19:01 +0200)
24 files changed:
data/common.yaml
data/nodes/bendel.debian.org.yaml
data/nodes/buxtehude.debian.org.yaml
data/nodes/draghi.debian.org.yaml
data/nodes/godard.debian.org.yaml
data/nodes/mailly.debian.org.yaml
data/nodes/muffat.debian.org.yaml
data/nodes/nono.debian.org.yaml
data/nodes/picconi.debian.org.yaml
data/nodes/pinel.debian.org.yaml
data/nodes/quantz.debian.org.yaml
data/nodes/reger.debian.org.yaml
data/nodes/tye.debian.org.yaml
data/nodes/vento.debian.org.yaml
data/nodes/wuiet.debian.org.yaml
hieradata/nodes/master.debian.org.yaml [new file with mode: 0644]
manifests/site.pp
modules/base/manifests/includes.pp
modules/exim/manifests/init.pp
modules/exim/manifests/mx.pp
modules/exim/templates/eximconf.erb
modules/nagios/manifests/server.pp
modules/roles/manifests/mailrelay.pp
modules/roles/manifests/mta.pp [new file with mode: 0644]

index e53f7e4..e724e5f 100644 (file)
@@ -12,6 +12,7 @@ resolv::nameservers: []
 resolv::searchpaths: ['debian.org']
 staticsync::user: 'staticsync'
 staticsync::basedir: '/srv/static.debian.org'
+exim::smarthost: 'mailout.debian.org'
 
 roles::dns_primary::allow_access:
   # easydns
index 0796435..7b8c896 100644 (file)
@@ -2,4 +2,5 @@
 classes:
   - roles::lists
 
+roles::mta::type: 'postfix'
 postfix::manage_maincf: false
index b93b964..498ea14 100644 (file)
@@ -6,4 +6,5 @@ apache2::smaller_number_of_threads: true
 # debbugs cgis like to fork and don't deal well with EAGAIN
 apache2::rlimitnproc: 450
 
+roles::mta::heavy: true
 exim::is_bugsmx: true
index a2da6fd..22dd9cf 100644 (file)
@@ -1,3 +1,5 @@
 ---
 classes:
   - roles::dbmaster
+
+roles::mta::heavy: true
index 65baf3d..bc631fe 100644 (file)
@@ -2,3 +2,4 @@ classes:
   - salsa
 
 ssl::insecure_ssl: true
+roles::mta::type: 'postfix'
index 806a802..1d9d610 100644 (file)
@@ -1,5 +1,2 @@
 ---
-classes:
-  - roles::mailrelay
-
-exim::is_mailrelay: true
+roles::mta::mailrelay: true
index 806a802..1d9d610 100644 (file)
@@ -1,5 +1,2 @@
 ---
-classes:
-  - roles::mailrelay
-
-exim::is_mailrelay: true
+roles::mta::mailrelay: true
index 50b0935..fa2ac0e 100644 (file)
@@ -2,3 +2,5 @@
 classes:
   - roles::contributors
   - roles::nm
+
+roles::mta::heavy: true
index 96e5afa..fbb0873 100644 (file)
@@ -3,3 +3,4 @@ classes:
   - roles::packages
 
 exim::is_packagesmaster: true
+roles::mta::heavy: true
index d8342f7..08a6327 100644 (file)
@@ -1,4 +1,6 @@
 ---
-apache2::smaller_number_of_threads: true
 classes:
   - roles::popcon
+
+apache2::smaller_number_of_threads: true
+roles::mta::heavy: true
index 1b90037..7d117b0 100644 (file)
@@ -7,3 +7,5 @@ apache2::mpm: prefork
 apache2::rlimitmem: 314572800
 
 exim::is_packagesqamaster: true
+
+roles::mta::heavy: true
index dc19277..8271be5 100644 (file)
@@ -1,4 +1,6 @@
 ---
 classes:
   - roles::rtmaster
+
 exim::is_rtmaster: true
+roles::mta::heavy: true
index b8e7d38..72d13e0 100644 (file)
@@ -2,3 +2,5 @@
 classes:
   - roles::i18n
   - roles::l10n
+
+roles::mta::heavy: true
index 796f4e3..3b4fced 100644 (file)
@@ -1,3 +1,5 @@
 ---
 classes:
   - roles::vote
+
+roles::mta::heavy: true
index 21baec7..94ee4da 100644 (file)
@@ -3,3 +3,4 @@ classes:
   - roles::buildd_master
 
 apache2::mpm: prefork
+roles::mta::heavy: true
diff --git a/hieradata/nodes/master.debian.org.yaml b/hieradata/nodes/master.debian.org.yaml
new file mode 100644 (file)
index 0000000..891db1f
--- /dev/null
@@ -0,0 +1,2 @@
+---
+roles::mta::heavy: true
index 6ff112d..29ac94f 100644 (file)
@@ -41,18 +41,6 @@ node default {
                include acpi
        }
 
-       if $::mta == 'exim4' {
-               if getfromhash($deprecated::nodeinfo, 'heavy_exim') {
-                       include exim::mx
-               } else {
-                       include exim
-               }
-       } elsif $::mta == 'postfix' {
-               include postfix
-       } else {
-               include exim
-       }
-
        if $::apache2 {
                include apache2
        }
index d873544..9102c2c 100644 (file)
@@ -1,4 +1,6 @@
 class base::includes {
+  include mta
+
   include munin
   include syslog_ng
   include sudo
index fec2db5..fd41732 100644 (file)
@@ -1,4 +1,13 @@
+# our exim class
+# @param smarthost host to relay through (if unset)
+# @param is_bugsmx this system handles bugs.debian.org
+# @param is_mailrelay this system is a mailrelay, both in and out, for debian hosts
+# @param is_rtmaster this system handles rt.debian.org
+# @param is_packagesmaster this system handles packagesrt.debian.org
+# @param is_packagesqamaster this system handles packages.qa.debian.org
+# @param smarthost_port the port on which satellites send mail to the smarthost
 class exim (
+  Optional[String] $smarthost,
   Boolean $is_bugsmx = false,
   Boolean $is_mailrelay = false,
   Boolean $is_rtmaster = false,
@@ -9,6 +18,12 @@ class exim (
   include exim::vdomain::setup
   include debian_org::mail_incoming_port
 
+  if $smarthost {
+    $heavy = false
+  } else {
+    $heavy = true
+  }
+
   munin::check { 'ps_exim4': script => 'ps_' }
   munin::check { 'exim_mailqueue': }
   munin::check { 'exim_mailstats': }
index 833ba26..fa36ec8 100644 (file)
@@ -1,4 +1,9 @@
-class exim::mx inherits exim {
+# our heavy exim class
+class exim::mx {
+  class { 'exim':
+    smarthost => Undef,
+  }
+
   include clamav
   include postgrey
   include fail2ban::exim
index 27f06b9..7cd6738 100644 (file)
@@ -76,7 +76,7 @@
 #                    MAIN CONFIGURATION SETTINGS                     #
 ######################################################################
 
-<%- if scope.lookupvar('deprecated::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('deprecated::nodeinfo')['heavy_exim'] -%>
+<%- if @heavy -%>
  perl_startup = do '/etc/exim4/exim_surbl.pl'
 <%- end -%>
 
@@ -87,7 +87,7 @@
 acl_smtp_helo = check_helo
 acl_smtp_rcpt = ${if ={$interface_port}{587} {check_submission}{check_recipient}}
 acl_smtp_data = check_message
-<%- if scope.lookupvar('deprecated::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('deprecated::nodeinfo')['heavy_exim'] -%>
+<%- if @heavy -%>
 acl_smtp_mime = acl_check_mime
 <%- end -%>
 acl_smtp_predata = acl_check_predata
@@ -174,7 +174,7 @@ timeout_frozen_after=14d
 message_size_limit = 100M
 message_logs = false
 smtp_accept_max_per_host = ${if match_ip {$sender_host_address}{+debianhosts}{0}{7}}
-<%- if scope.lookupvar('deprecated::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('deprecated::nodeinfo')['heavy_exim'] -%>
+<%- if @heavy -%>
 smtp_accept_max = 300
 smtp_accept_queue = 200
 smtp_accept_queue_per_connection = 50
@@ -193,7 +193,7 @@ check_spool_space  = 20M
 
 delay_warning =
 
-<%- if scope.lookupvar('deprecated::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('deprecated::nodeinfo')['heavy_exim'] -%>
+<%- if @heavy -%>
 message_body_visible = 5000
 queue_run_max = 50
 deliver_queue_load_max = 50
@@ -409,7 +409,7 @@ check_helo:
   accept  verify   = certificate
 
 <%- end -%>
-<%- if scope.lookupvar('deprecated::nodeinfo')['smarthost'].empty? -%>
+<%- unless @smarthost -%>
   # These are in HELO acl so that they are only run once.  They increment a counter,
   # so we don't want it to increment per rcpt to.
 
@@ -817,7 +817,7 @@ check_recipient:
   accept  local_parts   = +postmasterish
           domains       = +virtual_domains : +bsmtp_domains
 
-<%- if scope.lookupvar('deprecated::nodeinfo')['smarthost'].empty? -%>
+<%- unless @smarthost -%>
   deny    message  = host $sender_host_address is listed in $dnslist_domain; see $dnslist_text
           dnslists = ${if match_domain{$domain}{+virtual_domains}\
                     {${if exists {${extract{directory}{VDOMAINDATA}{${value}/rbllist}}}\
@@ -837,7 +837,7 @@ check_recipient:
          domains       = +handled_domains
          !hosts        = +debianhosts : WHITELIST
 
-<%- if scope.lookupvar('deprecated::nodeinfo')['smarthost'].empty? -%>
+<%- unless @smarthost -%>
   deny    domains  = +handled_domains
           local_parts = ${if match_domain{$domain}{+virtual_domains}\
                         {${if exists {${extract{directory}{VDOMAINDATA}{${value}/callout_users}}}\
@@ -865,7 +865,7 @@ check_recipient:
 
   deny    message = relay not permitted
 
-<%- if scope.lookupvar('deprecated::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('deprecated::nodeinfo')['heavy_exim'] -%>
+<%- if @heavy -%>
 acl_check_mime:
 
  accept  verify        = certificate
@@ -980,7 +980,7 @@ check_message:
           message         = X-malware detected: $malware_name
 
 <%- end -%>
-<%- if scope.lookupvar('deprecated::nodeinfo').has_key?('heavy_exim') and scope.lookupvar('deprecated::nodeinfo')['heavy_exim'] -%>
+<%- if @heavy -%>
  discard condition     = ${if <{$message_size}{256000}}
          condition     = ${if eq {$acl_m_prf}{blackhole}}
          set acl_m_srb = ${perl{surblspamcheck}}
@@ -1083,23 +1083,17 @@ ipliteral:
   transport = remote_smtp
   ignore_target_hosts = +reservedaddrs
 
-<%=
-out = ""
-if not scope.lookupvar('deprecated::nodeinfo')['smarthost'].empty?
-out = "
+<%- if @smarthost -%>
 smarthost:
   debug_print = \"R: smarthost for $local_part@$domain\"
   driver = manualroute
   domains = !+handled_domains
   transport = remote_smtp_smarthost
-  route_list = * #{scope.lookupvar('deprecated::nodeinfo')['smarthost']}
+  route_list = * <%= @smarthost %>
   host_find_failed = defer
   same_domain_copy_routing = yes
   no_more
-"
-end
-out
-%>
+<%- end -%>
 
 # This router routes to remote hosts over SMTP using a DNS lookup.
 # Ignore reserved network responses, including localhost.
@@ -1577,7 +1571,7 @@ remote_smtp:
   tls_certificate = /etc/exim4/ssl/thishost.crt
   tls_privatekey = /etc/exim4/ssl/thishost.key
 
-<%- if not scope.lookupvar('deprecated::nodeinfo')['smarthost'].empty? -%>
+<%- if @smarthost -%>
 remote_smtp_smarthost:
   debug_print = "T: remote_smtp_smarthost for $local_part@$domain"
   driver = smtp
index a8c1f63..2e7b1eb 100644 (file)
@@ -1,3 +1,7 @@
+# our nagios server class
+#
+# it includes stored ferm configs for all the things it needs to access
+# which are then collected by the monitored services
 class nagios::server {
   include apache2
   include apache2::ssl
index b84b13f..a888531 100644 (file)
@@ -7,6 +7,8 @@
 #   include roles::mailrelay
 #
 class roles::mailrelay {
+  include exim::mx
+
   include roles::pubsub::parameters
 
   $rabbit_password = $roles::pubsub::parameters::rabbit_password
diff --git a/modules/roles/manifests/mta.pp b/modules/roles/manifests/mta.pp
new file mode 100644 (file)
index 0000000..3ce4443
--- /dev/null
@@ -0,0 +1,27 @@
+# Every one of our hosts has an MTA
+#
+# @param type exim4 or postfix.  exim4 is our default MTA
+# @param heavy receive email from the internet and thus do spam filtering etc
+# @param mailrelay receive mail on other hosts' behalf.  implies heavy
+class roles::mta(
+  Enum['exim4', 'postfix'] $type = 'exim4',
+  Boolean $heavy = false,
+  Boolean $mailrelay = false,
+) {
+  if $type == 'exim4' {
+    if $mailrelay {
+      include roles::mailrelay
+    } elsif $heavy {
+      include exim::mx
+    } else {
+      include exim
+    }
+  } elsif $type == 'postfix' {
+    if $mailrelay {
+      fail("Unsupported: mailrelay on type ${type}")
+    }
+    include postfix
+  } else {
+    fail("Unexpected mta type ${type}")
+  }
+}