From d52dc2c7bdce4b967f7e3c08c657441da135be84 Mon Sep 17 00:00:00 2001
From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de>
Date: Tue, 11 Jan 2022 19:57:26 +0100
Subject: [PATCH] basic-system: fstrim cronjob

---
 basic-system/files/fstrim   |  5 +++++
 basic-system/tasks/main.yml | 10 ++++++++++
 2 files changed, 15 insertions(+)
 create mode 100755 basic-system/files/fstrim

diff --git a/basic-system/files/fstrim b/basic-system/files/fstrim
new file mode 100755
index 0000000..b1816b2
--- /dev/null
+++ b/basic-system/files/fstrim
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+if command -v fstrim >/dev/null; then
+    fstrim -a
+fi
diff --git a/basic-system/tasks/main.yml b/basic-system/tasks/main.yml
index 9f0ece0..a8b06fd 100644
--- a/basic-system/tasks/main.yml
+++ b/basic-system/tasks/main.yml
@@ -54,6 +54,16 @@
   tags:
     - etckeeper
 
+- name: Configure fstrim cronjob
+  copy:
+    src: fstrim
+    dest: /etc/cron.daily/fstrim
+    owner: root
+    group: root
+    mode: '0755'
+  tags:
+    - fstrim
+
 - include: logging.yml
 - meta: flush_handlers
 - include: network.yml
-- 
GitLab