]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - modules/role/manifests/cryptoportfolio.pp
Upgrade front version
[perso/Immae/Projets/Puppet.git] / modules / role / manifests / cryptoportfolio.pp
index 9ed3375aad8408a1314ed32c12b9484044fc5fa0..ee1c74f10f36a06a0d0ca71a00d462e09b7dfb24 100644 (file)
@@ -18,7 +18,9 @@ class role::cryptoportfolio {
   $cf_pg_db = "cryptoportfolio"
   $cf_pg_password = generate_password(24, $password_seed, "postgres_cryptoportfolio")
   $cf_pg_replication_password = generate_password(24, $password_seed, "postgres_cryptoportfolio_replication")
-  $cf_pg_host = "localhost:5432"
+  $cf_pg_hostname = "localhost"
+  $cf_pg_port = "5432"
+  $cf_pg_host = "${cf_pg_hostname}:${cf_pg_port}"
 
   $cf_user = "cryptoportfolio"
   $cf_group = "cryptoportfolio"
@@ -36,6 +38,8 @@ class role::cryptoportfolio {
   $cf_front_app_static_conf = "${cf_front_app}/cmd/web/env/prod.env"
 
   $cf_bot_app = "${cf_home}/bot"
+  $cf_bot_app_conf = "${cf_home}/bot_config.ini"
+  $cf_bot_app_reports = "${cf_home}/bot_reports"
 
   file { "/var/lib/postgres/data/certs":
     ensure  => directory,
@@ -212,6 +216,45 @@ class role::cryptoportfolio {
       command     => "/usr/bin/make install",
       require     => User[$cf_user],
       refreshonly => true,
+      before      => [
+        File[$cf_bot_app_conf],
+        Cron["py-cryptoportfolio-before"],
+        Cron["py-cryptoportfolio-after"],
+      ]
+    }
+
+    file { $cf_bot_app_conf:
+      owner   => $cf_user,
+      group   => $cf_group,
+      mode    => "0600",
+      content => template("role/cryptoportfolio/bot_config.ini.erb")
+    }
+
+    cron { "py-cryptoportfolio-before":
+      ensure      => present,
+      command     => "cd $cf_bot_app ; python main.py --config $cf_bot_app_conf --before",
+      user        => "cryptoportfolio",
+      weekday     => 7, # Sunday
+      hour        => 22,
+      minute      => 30,
+      environment => ["HOME=${cf_home}","PATH=/usr/bin/"],
+      require     => [
+        File[$cf_bot_app_conf],
+        Archive["${cf_home}/${bot_version}.tar.gz"]
+      ],
+    }
+
+    cron { "py-cryptoportfolio-after":
+      ensure      => present,
+      command     => "cd $cf_bot_app ; python main.py --config $cf_bot_app_conf --after",
+      user        => "cryptoportfolio",
+      weekday     => 1, # Monday
+      hour        => 1,
+      environment => ["HOME=${cf_home}","PATH=/usr/bin/"],
+      require     => [
+        File[$cf_bot_app_conf],
+        Archive["${cf_home}/${bot_version}.tar.gz"]
+      ],
     }
   }