]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - modules/role/manifests/cryptoportfolio.pp
Create cryptoportfolio user
[perso/Immae/Projets/Puppet.git] / modules / role / manifests / cryptoportfolio.pp
index 4643f9e03f2989e3f4a2cfba75659c8927d6a1ee..046b79ef3f223f4445ef4ee0e462c48fef2bf87b 100644 (file)
@@ -35,4 +35,52 @@ class role::cryptoportfolio {
   }
 
   ensure_packages(["go", "npm", "nodejs", "yarn"])
+
+  user { "cryptoportfolio":
+    name       => "cryptoportfolio",
+    ensure     => "present",
+    managehome => true,
+    home       => "/opt/cryptoportfolio",
+    system     => true,
+    password   => '!!',
+  }
+
+  $front_version = lookup("cryptoportfolio::front_version") |$key| { {} }
+  $front_sha256 = lookup("cryptoportfolio::front_sha256") |$key| { {} }
+
+  unless empty($front_version) {
+    file { "/opt/cryptoportfolio/front":
+      ensure => directory,
+      mode   => "0700",
+      owner  => "cryptoportfolio",
+      group  => "cryptoportfolio",
+    }
+
+    file { "/opt/cryptoportfolio/front/${front_version}":
+      ensure  => directory,
+      mode    => "0700",
+      owner   => "cryptoportfolio",
+      group   => "cryptoportfolio",
+      require => File["/opt/cryptoportfolio/front"],
+    }
+
+    archive { "/opt/cryptoportfolio/front/${front_version}.tar.gz":
+      path          => "/opt/cryptoportfolio/front/${front_version}.tar.gz",
+      source        => "https://git.immae.eu/releases/cryptoportfolio/front/front_${front_version}.tar.gz",
+      creates       => "/opt/cryptoportfolio/front/${front_version}/README.md",
+      checksum_type => "sha256",
+      checksum      => $front_sha256,
+      cleanup       => false,
+      extract       => true,
+      extract_path  => "/opt/cryptoportfolio/front/${front_version}",
+      require       => File["/opt/cryptoportfolio/front/${front_version}"],
+    }
+
+    file { "/opt/cryptoportfolio/front/current":
+      ensure  => "link",
+      target  => "/opt/cryptoportfolio/front/${front_version}",
+      require => Archive["/opt/cryptoportfolio/front/${front_version}.tar.gz"]
+    }
+  }
+
 }