]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - modules/role/manifests/cryptoportfolio/bot.pp
Use external module for cronjobs
[perso/Immae/Projets/Puppet.git] / modules / role / manifests / cryptoportfolio / bot.pp
index d8b377f255bb0885585090b418aface92f596f42..7b62ae0120f60acb6224f6a360fc70adfc539494 100644 (file)
@@ -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",
+      }
     ],
   }