ensure_packages(["python-pip", "python-virtualenv", "python-django", "uwsgi-plugin-python"])
$caldance_app = "${home}/app"
+ $caldance_app_old = "${home}/app_old"
+ $caldance_app_tmp = "${home}/app_tmp"
$pg_password = generate_password(24, $password_seed, "postgres_caldance")
$secret_key = generate_password(24, $password_seed, "secret_key_caldance")
$socket = "/run/caldance/app.sock"
+ $uwsgi_path = "${home}/virtualenv/bin/uwsgi"
+ $python_path = "${home}/virtualenv/bin/python"
+
$environment = {
"DB_NAME" => $pg_db,
"DB_USER" => $pg_user,
"DB_PORT" => $pg_port,
"SECRET_KEY" => $secret_key,
"DEBUG" => "False",
- "LOG_FILE" => "$home/caldev_django.log",
+ "LOG_FILE" => "$home/caldance.log",
"MEDIA_ROOT" => "$home/media",
}
file { $home:
mode => "0755",
}
- file { "${home}/caldev_django.log":
- mode => "0664",
+
+ file { $caldance_app_tmp:
+ ensure => "directory",
+ mode => "0755",
owner => $user,
- group => "http",
+ group => $group,
+ require => User["$user:"],
}
-
file { $caldance_app:
ensure => "directory",
mode => "0755",
user => $user,
username => lookup("base_installation::ldap_cn"),
password => generate_password(24, $password_seed, "ldap"),
- extract_path => $caldance_app,
- require => [User["$user:"], File[$caldance_app]],
+ extract_path => $caldance_app_tmp,
+ require => [User["$user:"], File[$caldance_app_tmp]],
} ~>
exec { "py-requirements":
- cwd => $caldance_app,
+ cwd => $caldance_app_tmp,
user => $user,
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,
} ~>
- exec { "py-migrate":
- cwd => $caldance_app,
- user => $user,
- environment => ["HOME=${home}"],
- command => "$caldance_app/manage migrate",
- require => [User["$user:"], File["$caldance_app/manage"]],
+ exec { "stop uwsgi application":
+ command => "/usr/bin/systemctl stop caldance-app.service || /usr/bin/true",
+ require => [User["$user:"]],
refreshonly => true,
} ~>
- exec { "py-static":
- cwd => $caldance_app,
+ exec { "mv app_tmp":
+ cwd => $home,
user => $user,
environment => ["HOME=${home}"],
- command => "$caldance_app/manage collectstatic --no-input",
- require => [User["$user:"], File["$caldance_app/manage"]],
+ command => "/usr/bin/rm -rf $caldance_app_old && /usr/bin/mv $caldance_app $caldance_app_old && /usr/bin/mv $caldance_app_tmp $caldance_app && /usr/bin/mkdir $caldance_app_tmp",
+ require => [User["$user:"]],
refreshonly => true,
} ~>
- exec { "restart uwsgi application":
- command => "/usr/bin/systemctl restart caldance-app.service",
- require => [User["$user:"], File["$caldance_app/app.ini"]],
- refreshonly => true,
- }
-
- $uwsgi_path = "${home}/virtualenv/bin/uwsgi"
- $python_path = "${home}/virtualenv/bin/python"
+ file { "$caldance_app/manage.py":
+ owner => $user,
+ group => $group,
+ mode => "0755",
+ 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,
content => template("role/caldance/manage.sh.erb"),
require => [
User["$user:"],
+ File["$caldance_app/manage.py"],
Archive[ "${home}/caldance_${caldance_version}.tar.gz"],
],
- }
-
+ } ~>
file { "$caldance_app/app.ini":
owner => $user,
group => $group,
User["$user:"],
Archive[ "${home}/caldance_${caldance_version}.tar.gz"],
],
+ } ~>
+ exec { "py-migrate":
+ cwd => $caldance_app,
+ user => $user,
+ 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 => ["HOME=${home}"],
+ command => "$caldance_app/manage collectstatic --no-input",
+ require => [User["$user:"], File["$caldance_app/manage"]],
+ refreshonly => true,
+ } ~>
+ exec { "restart uwsgi application":
+ command => "/usr/bin/systemctl restart caldance-app.service",
+ require => [User["$user:"], File["$caldance_app/app.ini"]],
+ refreshonly => true,
}
profile::postgresql::master { "postgresql master for caldance":