]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - modules/role/manifests/cryptoportfolio/front.pp
Change release url
[perso/Immae/Projets/Puppet.git] / modules / role / manifests / cryptoportfolio / front.pp
index 280ef8b1e8ce8c0ba972ba5d2e3b91dacf658b68..f969cd745f4e0cf128810b311e64142f011b7c99 100644 (file)
@@ -6,12 +6,16 @@ class role::cryptoportfolio::front inherits role::cryptoportfolio {
 
   $password_seed = lookup("base_installation::puppet_pass_seed")
 
-  $cf_front_app = "${home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front"
+  $cf_front_app = "${home}/go/src/git.immae.eu/Cryptoportfolio/Front"
   $cf_front_app_api_workdir = "${cf_front_app}/cmd/app"
   $cf_front_app_api_bin = "${cf_front_app_api_workdir}/cryptoportfolio-app"
   $cf_front_app_api_conf = "${home}/conf.toml"
   $cf_front_app_api_secret = generate_password(24, $password_seed, "cryptoportfolio_api_secret")
 
+  $cf_front_app_password_reset_secret = generate_password(24, $password_seed, "cryptoportfolio_api_password_reset_secret")
+  $cf_front_app_free_sms_user = lookup("role::cryptoportfolio::front::free_sms_user")
+  $cf_front_app_free_sms_pass = lookup("role::cryptoportfolio::front::free_sms_pass")
+
   $cf_front_app_static_conf = "${cf_front_app}/cmd/web/env/prod.env"
 
   ensure_packages(["go", "npm", "nodejs", "yarn"])
@@ -19,11 +23,8 @@ class role::cryptoportfolio::front inherits role::cryptoportfolio {
   file { [
       "${home}/go/",
       "${home}/go/src",
-      "${home}/go/src/immae.eu",
-      "${home}/go/src/immae.eu/Immae",
-      "${home}/go/src/immae.eu/Immae/Projets",
-      "${home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies",
-      "${home}/go/src/immae.eu/Immae/Projets/Cryptomonnaies/Cryptoportfolio",
+      "${home}/go/src/git.immae.eu",
+      "${home}/go/src/git.immae.eu/Cryptoportfolio",
       $cf_front_app]:
     ensure  => "directory",
     mode    => "0700",
@@ -64,7 +65,7 @@ class role::cryptoportfolio::front inherits role::cryptoportfolio {
 
   archive { "${home}/front_${front_version}.tar.gz":
     path          => "${home}/front_${front_version}.tar.gz",
-    source        => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz",
+    source        => "https://release.immae.eu/cryptoportfolio/front/front_${front_version}.tar.gz",
     checksum_type => "sha256",
     checksum      => $front_sha256,
     cleanup       => false,
@@ -139,6 +140,37 @@ class role::cryptoportfolio::front inherits role::cryptoportfolio {
     refreshonly => true,
   }
 
+  # Slack logger
+  $slack_logger = lookup("role::cryptoportfolio::front::slack_logger")
+  $slack_logger_username = lookup("role::cryptoportfolio::front::slack_logger_username", { "default_value" =>  "Logger" })
+
+  unless empty($slack_logger) {
+    file { "/usr/local/bin/api_logger":
+      mode    => "0755",
+      content => template("role/cryptoportfolio/api_logger.py.erb"),
+      notify  => Service["cryptoportfolio-log"],
+    }
+    ->
+    file { "/etc/systemd/system/cryptoportfolio-log.service":
+      mode    => "0644",
+      owner   => "root",
+      group   => "root",
+      content => template("role/cryptoportfolio/cryptoportfolio-log.service.erb"),
+      notify  => [
+        Exec["systemctl daemon-reload"],
+        Service["cryptoportfolio-log"]
+      ]
+    }
+    ->
+    service { 'cryptoportfolio-log':
+      enable    => true,
+      ensure    => "running",
+      require   => [
+        Service["cryptoportfolio-app"],
+      ],
+    }
+  }
+
   unless empty($webhook_url) {
     exec { "front-slack-notify":
       refreshonly => true,
@@ -155,4 +187,16 @@ class role::cryptoportfolio::front inherits role::cryptoportfolio {
     }
   }
 
+  @profile::monitoring::external_service { "Cryptoportfolio website is running on $web_host":
+    type   => "web",
+    master => {
+      check_command => "check_https!$web_host!/!<title>Cryptoportfolio"
+    }
+  }
+  @profile::monitoring::external_service { "$web_host ssl certificate is up to date":
+    type   => "web",
+    master => {
+      check_command => "check_https_certificate!$web_host"
+    }
+  }
 }