From 931dddda66f58b710f6a9734506e9b2cc50c9ebe Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 10 Jun 2019 18:10:11 +0200 Subject: [PATCH] Add wrapper to caldance app --- modules/role/manifests/caldance.pp | 29 ++++++++++++------- modules/role/templates/caldance/manage.sh.erb | 10 +++++++ 2 files changed, 29 insertions(+), 10 deletions(-) create mode 100644 modules/role/templates/caldance/manage.sh.erb diff --git a/modules/role/manifests/caldance.pp b/modules/role/manifests/caldance.pp index bd5e66c..d4c8207 100644 --- a/modules/role/manifests/caldance.pp +++ b/modules/role/manifests/caldance.pp @@ -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 index 0000000..ab08618 --- /dev/null +++ b/modules/role/templates/caldance/manage.sh.erb @@ -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 "$@" -- 2.41.0