ensure_packages(["python-pip", "python-virtualenv", "python-django"])
$caldance_app = "${home}/app"
+ $pg_password = generate_password(24, $password_seed, "postgres_caldance")
+ $secret_key = generate_password(24, $password_seed, "secret_key_caldance")
+
+ $environment = {
+ "DB_NAME" => $pg_db,
+ "DB_USER" => $pg_user,
+ "DB_PASSWORD" => $pg_password,
+ "DB_HOST" => $pg_hostname,
+ "DB_PORT" => $pg_port,
+ "SECRET_KEY" => $secret_key,
+ "DEBUG" => "False",
+ "LOG_FILE" => "$home/caldev_django.log",
+ "FROM_EMAIL" => $mail_from,
+ "EMAIL_HOST" => $smtp_host,
+ "EMAIL_PORT" => $smtp_port,
+ }
+ $shell_env = $environment.map |$key, $value| { "$key=$value" }
+ $apache_env = $environment.map |$key, $value| { "CALDANCE_$key $value" }
+
+ file { $home:
+ mode => "0755",
+ }
+ file { "${home}/caldev_django.log":
+ mode => "0664",
+ owner => $user,
+ group => "http",
+ content => "",
+ }
file { $caldance_app:
ensure => "directory",
exec { "py-requirements":
cwd => $caldance_app,
user => $user,
- environment => ["HOME=${home}"],
- command => "${home}/virtualenv/bin/pip install -r requirements.txt",
+ environment => concat(["HOME=${home}"], $shell_env),
+ command => "/usr/bin/sed -i -e '/GDAL/d' requirements.txt && ${home}/virtualenv/bin/pip install -r requirements.txt",
require => User["$user:"],
refreshonly => true,
} ~>
exec { "py-migrate":
cwd => $caldance_app,
user => $user,
- environment => ["HOME=${home}"],
+ environment => concat(["HOME=${home}"], $shell_env),
command => "$caldance_app/manage.py migrate",
- require => [User["$user:"], File["$caldance_app/manage.py"], File["$caldance_app/main_app/local_settings.py"]],
+ require => [User["$user:"], File["$caldance_app/manage.py"]],
refreshonly => true,
} ~>
exec { "py-static":
cwd => $caldance_app,
user => $user,
- environment => ["HOME=${home}"],
+ environment => concat(["HOME=${home}"], $shell_env),
command => "$caldance_app/manage.py collectstatic --no-input",
- require => [User["$user:"], File["$caldance_app/manage.py"], File["$caldance_app/main_app/local_settings.py"]],
+ 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"], File["$caldance_app/main_app/local_settings.py"]],
+ require => [User["$user:"], File["$caldance_app/manage.py"]],
refreshonly => true,
}
- $pg_password = generate_password(24, $password_seed, "postgres_caldance")
- $secret_key = generate_password(24, $password_seed, "secret_key_caldance")
- file { "$caldance_app/main_app/local_settings.py":
- owner => $user,
- group => $group,
- mode => "0644",
- content => template("role/caldance/local_settings.py.erb"),
- require => [
- User["$user:"],
- Archive[ "${home}/caldance_${caldance_version}.tar.gz"],
- ],
- }
-
$python_path = "${home}/virtualenv/bin/python"
file { "$caldance_app/manage.py":
owner => $user,
ensure_packages(["mod_wsgi"])
class { 'apache::mod::wsgi':
- wsgi_python_home => "$web_home/caldev_virtualenv",
- wsgi_python_path => "$web_home/caldev/www.cal-dance.com/",
+ wsgi_python_home => "${home}/virtualenv",
+ wsgi_python_path => $caldance_app,
require => Package["mod_wsgi"],
}
class { 'apache::mod::authn_file': }
require => Letsencrypt::Certonly[$web_host],
directories => [
{
- path => "$web_home/caldev/www.cal-dance.com/main_app",
+ path => "$caldance_app/main_app",
require => "all granted",
},
{
- path => "$web_home/caldev/www.cal-dance.com/www/static",
+ path => "$caldance_app/www/static",
require => "all granted",
},
{
aliases => [
{
alias => "/static/",
- path => "$web_home/caldev/www.cal-dance.com/www/static/",
+ path => "$caldance_app/www/static/",
},
],
- wsgi_script_aliases => { "/" => "$web_home/caldev/www.cal-dance.com/main_app/wsgi.py" };
+ setenv => $apache_env,
+ wsgi_script_aliases => { "/" => "$caldance_app/main_app/wsgi.py" };
default: * => $::profile::apache::apache_vhost_default;
}
}