From 26f74e58ac2d999dce433d0d9e3ebfb5e9e16917 Mon Sep 17 00:00:00 2001
From: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
Date: Thu, 22 Aug 2024 13:10:23 +0200
Subject: [PATCH] fix(suse): skip service

SUSE based distributions do not use Cron, but instead a systemd
timer for running logrotate on a schedule.
As this timer is enabled through a systemd preset, skip the state
completely.

Signed-off-by: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
---
 logrotate/osfamilymap.yaml                | 1 +
 logrotate/service.sls                     | 4 ++++
 test/integration/default/controls/base.rb | 2 ++
 3 files changed, 7 insertions(+)

diff --git a/logrotate/osfamilymap.yaml b/logrotate/osfamilymap.yaml
index 8c0c396..b61caca 100644
--- a/logrotate/osfamilymap.yaml
+++ b/logrotate/osfamilymap.yaml
@@ -14,6 +14,7 @@ RedHat:
   default_config:
     dateext: true
 Suse:
+  service: null
   login_records_jobs: false
   default_config:
     dateext: true
diff --git a/logrotate/service.sls b/logrotate/service.sls
index 1dbb774..c1bcb26 100644
--- a/logrotate/service.sls
+++ b/logrotate/service.sls
@@ -3,6 +3,8 @@
 
 {% from "logrotate/map.jinja" import logrotate with context %}
 
+{%- if logrotate.service is not none %}
+
 include:
   - logrotate.config
   - logrotate.install
@@ -15,3 +17,5 @@ logrotate:
       - pkg: logrotate-pkg
       - file: logrotate-config
       - file: logrotate-directory
+
+{%- endif %}
diff --git a/test/integration/default/controls/base.rb b/test/integration/default/controls/base.rb
index 6cbc87b..95b7644 100644
--- a/test/integration/default/controls/base.rb
+++ b/test/integration/default/controls/base.rb
@@ -49,6 +49,8 @@ control 'logrotate.service.running' do
       'cronie'
     when 'redhat', 'fedora'
       'crond'
+    when 'suse'
+      'logrotate.timer'
     else
       'cron'
     end