]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/commitdiff
Add wrapper to caldance app
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 10 Jun 2019 16:10:11 +0000 (18:10 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 10 Jun 2019 16:17:43 +0000 (18:17 +0200)
modules/role/manifests/caldance.pp
modules/role/templates/caldance/manage.sh.erb [new file with mode: 0644]

index bd5e66c00943e5e13aa61d1cc748b59d683a13c2..d4c820769975f26c7d360b169b372073b608817f 100644 (file)
@@ -42,7 +42,6 @@ class role::caldance (
     "LOG_FILE"    => "$home/caldev_django.log",
     "MEDIA_ROOT"  => "$home/media",
   }
-  $shell_env = $environment.map |$key, $value| { "$key=$value" }
 
   file { $home:
     mode => "0755",
@@ -90,7 +89,7 @@ class role::caldance (
   exec { "py-requirements":
     cwd         => $caldance_app,
     user        => $user,
-    environment => concat(["HOME=${home}"], $shell_env),
+    environment => ["HOME=${home}"],
     command     => "/usr/bin/sed -i -e '/GDAL/d' requirements.txt && ${home}/virtualenv/bin/pip install -r requirements.txt --upgrade",
     require     => User["$user:"],
     refreshonly => true,
@@ -98,17 +97,17 @@ class role::caldance (
   exec { "py-migrate":
     cwd         => $caldance_app,
     user        => $user,
-    environment => concat(["HOME=${home}"], $shell_env),
-    command     => "$caldance_app/manage.py migrate",
-    require     => [User["$user:"], File["$caldance_app/manage.py"]],
+    environment => ["HOME=${home}"],
+    command     => "$caldance_app/manage migrate",
+    require     => [User["$user:"], File["$caldance_app/manage"]],
     refreshonly => true,
   } ~>
   exec { "py-static":
     cwd         => $caldance_app,
     user        => $user,
-    environment => concat(["HOME=${home}"], $shell_env),
-    command     => "$caldance_app/manage.py collectstatic --no-input",
-    require     => [User["$user:"], File["$caldance_app/manage.py"]],
+    environment => ["HOME=${home}"],
+    command     => "$caldance_app/manage collectstatic --no-input",
+    require     => [User["$user:"], File["$caldance_app/manage"]],
     refreshonly => true,
   } ~>
   exec { "restart uwsgi application":
@@ -122,13 +121,23 @@ class role::caldance (
   file { "$caldance_app/manage.py":
     owner   => $user,
     group   => $group,
-    mode    => "0755",
+    mode    => "0644",
     content => template("role/caldance/manage.py.erb"),
     require => [
       User["$user:"],
       Archive[ "${home}/caldance_${caldance_version}.tar.gz"],
     ],
   }
+  file { "$caldance_app/manage":
+    owner   => $user,
+    group   => $group,
+    mode    => "0755",
+    content => template("role/caldance/manage.sh.erb"),
+    require => [
+      User["$user:"],
+      Archive[ "${home}/caldance_${caldance_version}.tar.gz"],
+    ],
+  }
 
   file { "$caldance_app/app.ini":
     owner   => $user,
@@ -252,7 +261,7 @@ class role::caldance (
   cron::job { "list_outdated_pip_packages":
     ensure      => present,
     user        => $user,
-    environment => concat(["HOME=${home}","MAILTO=${mailtos}"], $shell_env),
+    environment => ["HOME=${home}","MAILTO=${mailtos}"],
     command     => "${home}/virtualenv/bin/pip list --outdated",
     minute      => "15",
     hour        => "0",
diff --git a/modules/role/templates/caldance/manage.sh.erb b/modules/role/templates/caldance/manage.sh.erb
new file mode 100644 (file)
index 0000000..ab08618
--- /dev/null
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+set -a
+<% @environment.each do |env, val| %>
+<%= env %>="<%= val %>"
+<% end %>
+source <%= @home %>/caldance_env
+set +a
+
+<%= @python_path %> -O <%= @caldance_app %>/manage.py "$@"