]> git.immae.eu Git - perso/Immae/Projets/Puppet.git/blobdiff - modules/role/manifests/caldance.pp
Add media root environment file
[perso/Immae/Projets/Puppet.git] / modules / role / manifests / caldance.pp
index 6bac0bcb924114a02d85389a403a7378a44082b0..7f17c10e2ff2692df3ef1fba7d70822990470c01 100644 (file)
@@ -12,10 +12,12 @@ class role::caldance (
   Optional[String] $pg_port          = "5432",
   Optional[String] $caldance_version = undef,
   Optional[String] $caldance_sha256  = undef,
+  Optional[Array]  $cron_pip         = [],
 ) {
   $password_seed = lookup("base_installation::puppet_pass_seed")
   include "base_installation"
 
+  include "profile::mail"
   include "profile::tools"
   include "profile::postgresql"
   include "profile::apache"
@@ -37,6 +39,7 @@ class role::caldance (
     "SECRET_KEY"  => $secret_key,
     "DEBUG"       => "False",
     "LOG_FILE"    => "$home/caldev_django.log",
+    "MEDIA_ROOT"  => "$home/media",
     "FROM_EMAIL"  => $mail_from,
     "EMAIL_HOST"  => $smtp_host,
     "EMAIL_PORT"  => $smtp_port,
@@ -59,6 +62,12 @@ class role::caldance (
     owner   => $user,
     group   => $group,
     require => User["$user:"],
+  } ->
+  file { "${home}/media":
+    ensure => "directory",
+    mode   => "0755",
+    owner  => "http",
+    group  => "http",
   }
 
   exec { "initialize_venv":
@@ -105,6 +114,14 @@ class role::caldance (
     require     => [User["$user:"], File["$caldance_app/manage.py"]],
     refreshonly => true,
   } ~>
+  exec { "py-symlink-file":
+    cwd         => $caldance_app,
+    user        => $user,
+    environment => concat(["HOME=${home}"], $shell_env),
+    command     => "/usr/bin/ln -sf ${home}/media www/media",
+    require     => [User["$user:"], File["$caldance_app/manage.py"]],
+    refreshonly => true,
+  } ~>
   exec { "reload httpd":
     command     => "/usr/bin/systemctl reload httpd",
     require     => [User["$user:"], File["$caldance_app/manage.py"]],
@@ -199,4 +216,15 @@ class role::caldance (
     wsgi_script_aliases => { "/" => "$caldance_app/main_app/wsgi.py" };
     default: *          => $::profile::apache::apache_vhost_default;
   }
+
+  $mailtos = join($cron_pip, ",")
+  cron::job { "list_outdated_pip_packages":
+    ensure      => present,
+    user        => $user,
+    environment => concat(["HOME=${home}","MAILTO=${mailtos}"], $shell_env),
+    command     => "${home}/virtualenv/bin/pip list --outdated",
+    minute      => "15",
+    hour        => "0",
+    require     => Exec["initialize_venv"],
+  }
 }