From 50a70d5df2f31772d3900596aaa2a7a110825292 Mon Sep 17 00:00:00 2001
From: Andreas Kempe <kempe@lysator.liu.se>
Date: Thu, 14 Apr 2022 18:37:14 +0200
Subject: [PATCH] remote_logging: add class for remote logging only

When timehost is running on a system that uses an SD card, we want to
limit wear to the local file system and only log remotely.
---
 files/rsyslog.conf          |  3 +++
 manifests/remote_logging.pp | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 files/rsyslog.conf
 create mode 100644 manifests/remote_logging.pp

diff --git a/files/rsyslog.conf b/files/rsyslog.conf
new file mode 100644
index 0000000..ee28bd2
--- /dev/null
+++ b/files/rsyslog.conf
@@ -0,0 +1,3 @@
+# NOTE: This file in managed by the timehost::remote_logging class.
+# Only log to the main log server to reduce local media wear.
+*.*                     @loghost.lysator.liu.se
diff --git a/manifests/remote_logging.pp b/manifests/remote_logging.pp
new file mode 100644
index 0000000..3b13001
--- /dev/null
+++ b/manifests/remote_logging.pp
@@ -0,0 +1,21 @@
+# Class for only logging to Lysator's log server.
+# Used to reduce wear to local storage.
+class timehost::remote_logging {
+  package { 'rsyslog':
+    ensure => present,
+  }
+
+  file {'/etc/rsyslog.conf':
+    ensure => present,
+    source => 'puppet:///modules/timehost/rsyslog.conf',
+    owner  => 'root',
+    group  => 'root',
+    mode   => '0644',
+    notify => Service['rsyslogd'],
+  }
+
+  service { 'rsyslogd':
+    ensure => running,
+    enable => true,
+  }
+}
-- 
GitLab