Clean up failed rsyncs every few minutes
authorPeter Palfrader <peter@palfrader.org>
Sun, 4 Feb 2018 12:07:56 +0000 (13:07 +0100)
committerPeter Palfrader <peter@palfrader.org>
Sun, 4 Feb 2018 12:07:56 +0000 (13:07 +0100)
modules/rsync/files/systemd-cleanup-failed-rsyncs [new file with mode: 0755]
modules/rsync/manifests/init.pp

diff --git a/modules/rsync/files/systemd-cleanup-failed-rsyncs b/modules/rsync/files/systemd-cleanup-failed-rsyncs
new file mode 100755 (executable)
index 0000000..5cde92b
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# if a client goes away on socket activated connections before systemd launches
+# the process, things go sad and result in failed services.
+#
+# cf. https://github.com/systemd/systemd/issues/7172
+#
+# should be fixed in buster and newer, but for now clean those up.
+
+systemctl --failed --no-legend | awk '{print $1}' | \
+    while read service; do
+    if [[ $service =~ ^rsyncd-[a-z]*@.*\.service$ ]]; then
+        systemctl reset-failed "$service"
+    fi
+done
index 267b59c..a80582c 100644 (file)
@@ -24,4 +24,15 @@ class rsync {
                rule        => '&SERVICE(tcp, 873)'
        }
 
+       file { '/usr/local/sbin/systemd-cleanup-failed-rsyncs':
+               source => 'puppet:///modules/rsync/systemd-cleanup-failed-rsyncs',
+               mode   => '0555',
+       }
+       file { '/etc/cron.d/puppet-crazy-multipath-restart': ensure => absent, }
+       concat::fragment { 'dsa-puppet-stuff--systemd-cleanup-failed-rsyncs':
+               target => '/etc/cron.d/dsa-puppet-stuff',
+               content  => @("EOF"),
+                               */10 * * * * root /usr/local/sbin/systemd-cleanup-failed-rsyncs
+                               | EOF
+       }
 }