From 2859008efe8f0a75344c7ba1c9c6e4d589f92da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 26 Mar 2018 00:41:55 +0200 Subject: Use external module for cronjobs --- modules/role/manifests/backup.pp | 2 +- modules/role/manifests/cryptoportfolio/bot.pp | 40 +++++++++++++-------------- 2 files changed, 20 insertions(+), 22 deletions(-) (limited to 'modules/role/manifests') diff --git a/modules/role/manifests/backup.pp b/modules/role/manifests/backup.pp index 7a0c275..510a8ef 100644 --- a/modules/role/manifests/backup.pp +++ b/modules/role/manifests/backup.pp @@ -41,7 +41,7 @@ class role::backup ( mode => "0755", } - cron { "backup": + cron::job { "backup": ensure => present, command => $backup_script, user => $user, diff --git a/modules/role/manifests/cryptoportfolio/bot.pp b/modules/role/manifests/cryptoportfolio/bot.pp index d8b377f..7b62ae0 100644 --- a/modules/role/manifests/cryptoportfolio/bot.pp +++ b/modules/role/manifests/cryptoportfolio/bot.pp @@ -37,8 +37,7 @@ class role::cryptoportfolio::bot inherits role::cryptoportfolio { refreshonly => true, before => [ File[$cf_bot_app_conf], - Cron["py-cryptoportfolio-before"], - Cron["py-cryptoportfolio-after"], + Cron::Job::Multiple["py-cryptoportfolio"], ] } @@ -54,31 +53,30 @@ class role::cryptoportfolio::bot inherits role::cryptoportfolio { ], } - cron { "py-cryptoportfolio-before": + cron::job::multiple { "py-cryptoportfolio": ensure => present, - command => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --before", - user => $user, - weekday => 7, # Sunday - hour => 22, - minute => 30, environment => ["HOME=${home}","PATH=/usr/bin/","CRON_TZ=UTC"], require => [ File[$cf_bot_app_conf], Archive["${home}/trader_${bot_version}.tar.gz"] ], - } - - cron { "py-cryptoportfolio-after": - ensure => present, - command => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --after", - user => $user, - weekday => 1, # Monday - hour => 0, - minute => 0, - environment => ["HOME=${home}","PATH=/usr/bin/","CRON_TZ=UTC"], - require => [ - File[$cf_bot_app_conf], - Archive["${home}/trader_${bot_version}.tar.gz"] + jobs => [ + { + command => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --before", + user => $user, + weekday => 7, # Sunday + hour => 22, + minute => 30, + description => "Run before the cryptoportfolio update", + }, + { + command => "cd $cf_bot_app ; python main.py --quiet --config $cf_bot_app_conf --after", + user => $user, + weekday => 1, # Monday + hour => 0, + minute => 0, + description => "Run after the cryptoportfolio update", + } ], } -- cgit v1.2.3