From a478c773eb4fe847b0c3695bcb7cea4fe398a9b1 Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Mon, 30 Sep 2019 14:12:38 +0200 Subject: [PATCH] apt: check if cron is installed before adding a cron job --- CHANGELOG.md | 1 + apt/tasks/hold_packages.yml | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b3dbe9e..e0a217fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ The **patch** part changes incrementally at each release. ## [Unreleased] ### Added +* apt: check if cron is installed before adding a cron job * certbot : new role to install and configure certbot * evocheck: explicit PATH * evolinux-base: On debian 10 and later, add noexec on /dev/shm diff --git a/apt/tasks/hold_packages.yml b/apt/tasks/hold_packages.yml index b44a1581..7ab37a7f 100644 --- a/apt/tasks/hold_packages.yml +++ b/apt/tasks/hold_packages.yml @@ -55,6 +55,13 @@ tags: - apt +- name: Check if Cron is installed + shell: "dpkg --list 'cron' 2>/dev/null | grep -q -E '^(i|h)i'" + register: is_cron + changed_when: false + failed_when: false + check_mode: no + - name: Check for held packages (script) cron: cron_file: apt-hold-packages @@ -67,5 +74,6 @@ day: "{{ apt_check_hold_cron_day }}" month: "{{ apt_check_hold_cron_month }}" state: "present" + when: is_cron.rc == 0 tags: - apt