]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Add bot package
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 24 Feb 2018 22:31:16 +0000 (23:31 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Sat, 24 Feb 2018 22:32:39 +0000 (23:32 +0100)
environments/production/data/nodes/vps494082.yaml
modules/role/manifests/cryptoportfolio.pp

index 4b76ac6db3beb15db4e70a95f5c64f1358220866..59b2447100bac1d711261318a12bdbadae41f01c 100644 (file)
@@ -1,3 +1,5 @@
 base_installation::system_hostname: cryptoportfolio.immae.eu
 cryptoportfolio::front_version: v0.0.1-2-g989fb5c
 cryptoportfolio::front_sha256: 1e82044b6a40b415913658bb1b896087d8c2c43d64c5862cd84f60804f5854dc
+cryptoportfolio::bot_version: v0.1
+cryptoportfolio::bot_sha256: bb974d6b42714929b80262979e026813cfdad1f49de23fa789acb3aef8a2e315
index d670486362adf528e0a91a4a4225b005f7b306fb..9ed3375aad8408a1314ed32c12b9484044fc5fa0 100644 (file)
@@ -35,6 +35,8 @@ class role::cryptoportfolio {
 
   $cf_front_app_static_conf = "${cf_front_app}/cmd/web/env/prod.env"
 
+  $cf_bot_app = "${cf_home}/bot"
+
   file { "/var/lib/postgres/data/certs":
     ensure  => directory,
     mode    => "0700",
@@ -176,6 +178,43 @@ class role::cryptoportfolio {
   $front_version = lookup("cryptoportfolio::front_version") |$key| { {} }
   $front_sha256 = lookup("cryptoportfolio::front_sha256") |$key| { {} }
 
+  $bot_version = lookup("cryptoportfolio::bot_version") |$key| { {} }
+  $bot_sha256 = lookup("cryptoportfolio::bot_sha256") |$key| { {} }
+
+  unless empty($bot_version) {
+    ensure_packages(["python", "python-pip"])
+
+    file { $cf_bot_app:
+      ensure  => "directory",
+      mode    => "0700",
+      owner   => $cf_user,
+      group   => $cf_group,
+      require => User[$cf_user],
+    }
+
+    archive { "${cf_home}/${bot_version}.tar.gz":
+      path          => "${cf_home}/${bot_version}.tar.gz",
+      source        => "https://git.immae.eu/releases/cryptoportfolio/trader/trader_${bot_version}.tar.gz",
+      checksum_type => "sha256",
+      checksum      => $bot_sha256,
+      cleanup       => false,
+      extract       => true,
+      user          => "cryptoportfolio",
+      username      => $facts["ec2_metadata"]["hostname"],
+      password      => generate_password(24, $password_seed, "ldap"),
+      extract_path  => $cf_bot_app,
+      require       => [User[$cf_user], File[$cf_bot_app]],
+    } ~>
+    exec { "py-cryptoportfolio-dependencies":
+      cwd         => $cf_bot_app,
+      user        => $cf_user,
+      environment => ["HOME=${cf_home}"],
+      command     => "/usr/bin/make install",
+      require     => User[$cf_user],
+      refreshonly => true,
+    }
+  }
+
   unless empty($front_version) {
     ensure_packages(["go", "npm", "nodejs", "yarn"])