From e19284ef410d0d26adac312f313c9c783b0959d9 Mon Sep 17 00:00:00 2001
From: Thomas Schneider <thomas@fsmpi.rwth-aachen.de>
Date: Sun, 17 Dec 2017 13:24:45 +0100
Subject: [PATCH] Ensure services always run

---
 journal-remote/files/restart.conf |  2 ++
 journal-remote/tasks/main.yml     | 11 +++++++++++
 journal-upload/files/restart.conf |  2 ++
 journal-upload/handlers/main.yml  |  3 +++
 journal-upload/tasks/main.yml     | 19 +++++++++++++++++++
 5 files changed, 37 insertions(+)
 create mode 100644 journal-remote/files/restart.conf
 create mode 100644 journal-upload/files/restart.conf

diff --git a/journal-remote/files/restart.conf b/journal-remote/files/restart.conf
new file mode 100644
index 0000000..8a764e3
--- /dev/null
+++ b/journal-remote/files/restart.conf
@@ -0,0 +1,2 @@
+[Service]
+Restart=always
diff --git a/journal-remote/tasks/main.yml b/journal-remote/tasks/main.yml
index 16c9bfc..bf64c95 100644
--- a/journal-remote/tasks/main.yml
+++ b/journal-remote/tasks/main.yml
@@ -31,6 +31,17 @@
     - journal-remote
     - config
 
+- name: Ensure systemd-journal-remote always runs
+  copy:
+    dest: /etc/systemd/system/systemd-journal-remote.service.d/restart.conf
+    src: restart.conf
+  notify:
+    - Reload systemd
+    - Restart systemd-journal-remote
+  tags:
+    - journal-remote
+    - config
+
 - name: Ensure journal-remote directory is present
   file:
     path: /var/log/journal/remote
diff --git a/journal-upload/files/restart.conf b/journal-upload/files/restart.conf
new file mode 100644
index 0000000..8a764e3
--- /dev/null
+++ b/journal-upload/files/restart.conf
@@ -0,0 +1,2 @@
+[Service]
+Restart=always
diff --git a/journal-upload/handlers/main.yml b/journal-upload/handlers/main.yml
index ab453e7..ce61d94 100644
--- a/journal-upload/handlers/main.yml
+++ b/journal-upload/handlers/main.yml
@@ -1,2 +1,5 @@
+- name: Reload systemd
+  systemd: daemon-reload=yes
+
 - name: Restart systemd-journal-upload
   systemd: name=systemd-journal-upload state=restarted
diff --git a/journal-upload/tasks/main.yml b/journal-upload/tasks/main.yml
index 291dcae..fbca18f 100644
--- a/journal-upload/tasks/main.yml
+++ b/journal-upload/tasks/main.yml
@@ -19,6 +19,25 @@
         - journal-upload
         - config
 
+    - name: Ensure presence of unit drop-in config directory
+      file:
+        path: /etc/systemd/system/systemd-journal-upload.service.d
+        state: directory
+      tags:
+        - journal-upload
+        - config
+
+    - name: Ensure systemd-journal-upload always runs
+      copy:
+        dest: /etc/systemd/system/systemd-journal-upload.service.d/restart.conf
+        src: restart.conf
+      notify:
+        - Reload systemd
+        - Restart systemd-journal-upload
+      tags:
+        - journal-upload
+        - config
+
     - name: Enable journal-upload service
       systemd:
         name: systemd-journal-upload.service
-- 
GitLab