+ $caldance_app = "${home}/app"
+
+ file { $caldance_app:
+ ensure => "directory",
+ mode => "0755",
+ owner => $user,
+ group => $group,
+ require => User["$user:"],
+ }
+
+ exec { "initialize_venv":
+ user => $user,
+ require => User["$user:"],
+ command => "/usr/bin/virtualenv ${home}/virtualenv",
+ creates => "${home}/virtualenv",
+ }
+ ->
+ archive { "${home}/caldance_${caldance_version}.tar.gz":
+ path => "${home}/caldance_${caldance_version}.tar.gz",
+ source => "https://release.immae.eu/caldance/caldance_${caldance_version}.tar.gz",
+ checksum_type => "sha256",
+ checksum => $caldance_sha256,
+ cleanup => false,
+ extract => true,
+ 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]],
+ } ~>
+ exec { "py-requirements":
+ cwd => $caldance_app,
+ user => $user,
+ environment => ["HOME=${home}"],
+ command => "${home}/virtualenv/bin/pip install -r requirements.txt",
+ require => User["$user:"],
+ refreshonly => true,
+ } ~>
+ exec { "py-migrate":
+ cwd => $caldance_app,
+ user => $user,
+ environment => ["HOME=${home}"],
+ command => "$caldance_app/manage.py migrate",
+ require => [User["$user:"], File["$caldance_app/manage.py"], File["$caldance_app/main_app/local_settings.py"]],
+ refreshonly => true,
+ } ~>
+ exec { "py-static":
+ cwd => $caldance_app,
+ user => $user,
+ environment => ["HOME=${home}"],
+ command => "$caldance_app/manage.py collectstatic --no-input",
+ require => [User["$user:"], File["$caldance_app/manage.py"], File["$caldance_app/main_app/local_settings.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"]],
+ 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,
+ group => $group,
+ mode => "0755",
+ content => template("role/caldance/manage.py.erb"),
+ require => [
+ User["$user:"],
+ Archive[ "${home}/caldance_${caldance_version}.tar.gz"],
+ ],
+ }
+
+ profile::postgresql::master { "postgresql master for caldance":
+ letsencrypt_host => $web_host,
+ backup_hosts => ["backup-1"],
+ }
+
+ postgresql::server::db { $pg_db:
+ user => $pg_user,
+ password => postgresql_password($pg_user, $pg_password),
+ }
+