diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-06-10 18:10:11 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-06-10 18:17:43 +0200 |
commit | 931dddda66f58b710f6a9734506e9b2cc50c9ebe (patch) | |
tree | fede086d22eed0c1cce2d185afe0a02b392ca1f4 | |
parent | 02a6bcd123c6ace5926eac019f7964d0cf23de8a (diff) | |
download | Puppet-931dddda66f58b710f6a9734506e9b2cc50c9ebe.tar.gz Puppet-931dddda66f58b710f6a9734506e9b2cc50c9ebe.tar.zst Puppet-931dddda66f58b710f6a9734506e9b2cc50c9ebe.zip |
Add wrapper to caldance app
-rw-r--r-- | modules/role/manifests/caldance.pp | 29 | ||||
-rw-r--r-- | modules/role/templates/caldance/manage.sh.erb | 10 |
2 files changed, 29 insertions, 10 deletions
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 ( | |||
42 | "LOG_FILE" => "$home/caldev_django.log", | 42 | "LOG_FILE" => "$home/caldev_django.log", |
43 | "MEDIA_ROOT" => "$home/media", | 43 | "MEDIA_ROOT" => "$home/media", |
44 | } | 44 | } |
45 | $shell_env = $environment.map |$key, $value| { "$key=$value" } | ||
46 | 45 | ||
47 | file { $home: | 46 | file { $home: |
48 | mode => "0755", | 47 | mode => "0755", |
@@ -90,7 +89,7 @@ class role::caldance ( | |||
90 | exec { "py-requirements": | 89 | exec { "py-requirements": |
91 | cwd => $caldance_app, | 90 | cwd => $caldance_app, |
92 | user => $user, | 91 | user => $user, |
93 | environment => concat(["HOME=${home}"], $shell_env), | 92 | environment => ["HOME=${home}"], |
94 | command => "/usr/bin/sed -i -e '/GDAL/d' requirements.txt && ${home}/virtualenv/bin/pip install -r requirements.txt --upgrade", | 93 | command => "/usr/bin/sed -i -e '/GDAL/d' requirements.txt && ${home}/virtualenv/bin/pip install -r requirements.txt --upgrade", |
95 | require => User["$user:"], | 94 | require => User["$user:"], |
96 | refreshonly => true, | 95 | refreshonly => true, |
@@ -98,17 +97,17 @@ class role::caldance ( | |||
98 | exec { "py-migrate": | 97 | exec { "py-migrate": |
99 | cwd => $caldance_app, | 98 | cwd => $caldance_app, |
100 | user => $user, | 99 | user => $user, |
101 | environment => concat(["HOME=${home}"], $shell_env), | 100 | environment => ["HOME=${home}"], |
102 | command => "$caldance_app/manage.py migrate", | 101 | command => "$caldance_app/manage migrate", |
103 | require => [User["$user:"], File["$caldance_app/manage.py"]], | 102 | require => [User["$user:"], File["$caldance_app/manage"]], |
104 | refreshonly => true, | 103 | refreshonly => true, |
105 | } ~> | 104 | } ~> |
106 | exec { "py-static": | 105 | exec { "py-static": |
107 | cwd => $caldance_app, | 106 | cwd => $caldance_app, |
108 | user => $user, | 107 | user => $user, |
109 | environment => concat(["HOME=${home}"], $shell_env), | 108 | environment => ["HOME=${home}"], |
110 | command => "$caldance_app/manage.py collectstatic --no-input", | 109 | command => "$caldance_app/manage collectstatic --no-input", |
111 | require => [User["$user:"], File["$caldance_app/manage.py"]], | 110 | require => [User["$user:"], File["$caldance_app/manage"]], |
112 | refreshonly => true, | 111 | refreshonly => true, |
113 | } ~> | 112 | } ~> |
114 | exec { "restart uwsgi application": | 113 | exec { "restart uwsgi application": |
@@ -122,13 +121,23 @@ class role::caldance ( | |||
122 | file { "$caldance_app/manage.py": | 121 | file { "$caldance_app/manage.py": |
123 | owner => $user, | 122 | owner => $user, |
124 | group => $group, | 123 | group => $group, |
125 | mode => "0755", | 124 | mode => "0644", |
126 | content => template("role/caldance/manage.py.erb"), | 125 | content => template("role/caldance/manage.py.erb"), |
127 | require => [ | 126 | require => [ |
128 | User["$user:"], | 127 | User["$user:"], |
129 | Archive[ "${home}/caldance_${caldance_version}.tar.gz"], | 128 | Archive[ "${home}/caldance_${caldance_version}.tar.gz"], |
130 | ], | 129 | ], |
131 | } | 130 | } |
131 | file { "$caldance_app/manage": | ||
132 | owner => $user, | ||
133 | group => $group, | ||
134 | mode => "0755", | ||
135 | content => template("role/caldance/manage.sh.erb"), | ||
136 | require => [ | ||
137 | User["$user:"], | ||
138 | Archive[ "${home}/caldance_${caldance_version}.tar.gz"], | ||
139 | ], | ||
140 | } | ||
132 | 141 | ||
133 | file { "$caldance_app/app.ini": | 142 | file { "$caldance_app/app.ini": |
134 | owner => $user, | 143 | owner => $user, |
@@ -252,7 +261,7 @@ class role::caldance ( | |||
252 | cron::job { "list_outdated_pip_packages": | 261 | cron::job { "list_outdated_pip_packages": |
253 | ensure => present, | 262 | ensure => present, |
254 | user => $user, | 263 | user => $user, |
255 | environment => concat(["HOME=${home}","MAILTO=${mailtos}"], $shell_env), | 264 | environment => ["HOME=${home}","MAILTO=${mailtos}"], |
256 | command => "${home}/virtualenv/bin/pip list --outdated", | 265 | command => "${home}/virtualenv/bin/pip list --outdated", |
257 | minute => "15", | 266 | minute => "15", |
258 | hour => "0", | 267 | 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 @@ | |||
1 | #!/usr/bin/env bash | ||
2 | |||
3 | set -a | ||
4 | <% @environment.each do |env, val| %> | ||
5 | <%= env %>="<%= val %>" | ||
6 | <% end %> | ||
7 | source <%= @home %>/caldance_env | ||
8 | set +a | ||
9 | |||
10 | <%= @python_path %> -O <%= @caldance_app %>/manage.py "$@" | ||