From 7ac7c1a2b7773ef92d108e6c66364f5ab9205aa2 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Fri, 2 Jul 2021 06:36:51 +0200 Subject: [PATCH] bundles/cron: ensure cron is installed and running --- bundles/cron/items.py | 15 +++++++++++++++ bundles/cron/metadata.py | 12 ++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 bundles/cron/metadata.py diff --git a/bundles/cron/items.py b/bundles/cron/items.py index f6075f1..7ce8ec5 100644 --- a/bundles/cron/items.py +++ b/bundles/cron/items.py @@ -1,3 +1,10 @@ +if node.os == 'arch': + service_name = 'cronie' + package_name = 'pkg_pacman:cronie' +else: + service_name = 'cron' + package_name = 'pkg_apt:cron' + files = { '/etc/crontab': { 'content_type': 'mako', @@ -16,6 +23,14 @@ directories = { }, } +svc_systemd = { + service_name: { + 'needs': { + package_name, + }, + }, +} + for crontab, content in node.metadata.get('cron', {}).items(): files['/etc/cron.d/{}'.format(crontab)] = { 'source': 'cron_template', diff --git a/bundles/cron/metadata.py b/bundles/cron/metadata.py new file mode 100644 index 0000000..66d612a --- /dev/null +++ b/bundles/cron/metadata.py @@ -0,0 +1,12 @@ +defaults = { + 'apt': { + 'packages': { + 'cron': {}, + }, + }, + 'pacman': { + 'packages': { + 'cronie': {}, + }, + }, +}