From b5e4b036f52f0f6b3b102f67c4bdcd627294cb56 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Tue, 28 Apr 2020 09:51:17 +0200
Subject: [PATCH] Configure maintenance cron

---
 tasks/install.yml | 20 ++++++++++++++++++++
 tasks/main.yml    |  1 +
 2 files changed, 21 insertions(+)

diff --git a/tasks/install.yml b/tasks/install.yml
index 084cff1..67be2cd 100644
--- a/tasks/install.yml
+++ b/tasks/install.yml
@@ -174,3 +174,23 @@
   ignore_errors: yes
   tags:
     - deploy
+
+- name: Ensure Log Directory
+  file:
+    path: /var/log/matomo
+    state: directory
+    owner: '{{ apacheUser }}'
+    group: '{{ apacheUser }}'
+    mode: 0775
+  tags:
+    - cron
+
+- name: Configure cron
+  cron:
+    name: Matomo Cron {{ matomo.id }}
+    minute: 20
+    job: cd /var/www/matomo/{{ matomo.id }} && ./console core:archive --url=https://{{ matomo.domain }}/ >> /var/log/matomo/{{ matomo.id }}.log 2>&1
+    user: '{{ apacheUser }}'
+    disabled: '{{ crons_disabled|default(false) }}'
+  tags:
+    - cron
diff --git a/tasks/main.yml b/tasks/main.yml
index 9ceb317..c680e11 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -29,5 +29,6 @@
       tags:
         - ApacheConfig
         - deploy
+        - cron
 
   when: not excluded_roles or "matomo" not in excluded_roles
-- 
GitLab