Changeset View
Changeset View
Standalone View
Standalone View
site-modules/profile/manifests/hedgedoc.pp
- This file was added.
# deploy a hedgedoc instance | |||||
class profile::hedgedoc { | |||||
$packages = [ | |||||
'npm', 'yarn', 'node-gyp' | |||||
] | |||||
$keyid = lookup('yarn::apt_config::keyid') | |||||
$key = lookup('yarn::apt_config::key') | |||||
# ---- configuration | |||||
$user = lookup('hedgedoc::user') | |||||
$group = lookup('hedgedoc::group') | |||||
$host = lookup('hedgedoc::host') | |||||
$port = lookup('hedgedoc::port') | |||||
$base_url = "${host}:${port}" | |||||
$db_name = lookup('hedgedoc::db::db_name') | |||||
$db_user = lookup('hedgedoc::db::username') | |||||
$db_password = lookup('swh::deploy::hedgedoc::db::password') | |||||
$db_port = lookup('swh::postgresql::port') | |||||
$db_url = "postgres://${db_user}:${db_password}@${host}:${db_port}/${db_name}" | |||||
$allow_anonymous = lookup('hedgedoc::allow_anonymous') | |||||
$allow_anonymous_edits = lookup('hedgedoc::allow_anonymous_edits') | |||||
$runtime_environment = lookup('hedgedoc::runtime_environment') | |||||
$log_level = lookup('hedgedoc::log_level') | |||||
# ---- install | |||||
$version = "1.7.0" | |||||
$archive_url = "https://github.com/hedgedoc/hedgedoc/releases/download/${version}/hedgedoc-${version}.tar.gz" | |||||
$archive_path = "/tmp/hedgedoc-${version}.tar.gz" | |||||
$root_install_path = "/opt" | |||||
vsellier: WDYT about installing the files on `/opt/hedgedoc` ? | |||||
Done Inline Actionsindeed, /opt it should be. I just mapped to where i did my manual tryouts without thinking. ardumont: indeed, /opt it should be.
I just mapped to where i did my manual tryouts without thinking. | |||||
$install_path = "${root_install_path}/hedgedoc" | |||||
$upgrade_flag_path = "${install_path}/hedgedoc-${version}-upgrade" | |||||
$sequelizerc_config_sequelizerc_path = "${install_path}/.sequelizerc" | |||||
$sequelizerc_config_json_path = "${install_path}/config.json" | |||||
$service_name = "hedgedoc" | |||||
$unit_name = "${service_name}.service" | |||||
apt::source { 'yarn': | |||||
location => "https://dl.yarnpkg.com/debian/", | |||||
release => 'stable', | |||||
repos => 'main', | |||||
key => { | |||||
id => $keyid, | |||||
content => $key, | |||||
Done Inline Actions~> is equivalent to a notify, here, a strict require -> should be more appropriate to avoid any attempt to install the packages before the source is installed vsellier: `~>` is equivalent to a notify, here, a strict require `->` should be more appropriate to avoid… | |||||
}, | |||||
} -> | |||||
package { $packages: | |||||
ensure => present, | |||||
notify => Archive['hedgedoc'], | |||||
} | |||||
file { $install_path: | |||||
ensure => 'directory', | |||||
owner => $user, | |||||
group => $group, | |||||
mode => '0644', | |||||
require => [User[$user], Group[$group]], | |||||
} | |||||
Done Inline Actionsthe dependencies on the user and group should be explicitly declared vsellier: the dependencies on the user and group should be explicitly declared | |||||
archive { 'hedgedoc': | |||||
path => $archive_path, | |||||
extract => true, | |||||
source => $archive_url, | |||||
extract_path => $root_install_path, | |||||
creates => $install_path, | |||||
checksum => 'ab1fc7ddf260ca6caff52f3400fc38815481fe353d0edc08de721765f15071f6', | |||||
Not Done Inline ActionsShouldn't a condition on the presence of the flag be specified? vsellier: Shouldn't a condition on the presence of the flag be specified?
I'm afraid the upgrade will be… | |||||
checksum_type => 'sha256', | |||||
cleanup => true, | |||||
user => 'root', | |||||
group => 'root', | |||||
notify => File[$install_path], | |||||
} ~> | |||||
Done Inline Actionsshould be $user and $group ? vsellier: should be $user and $group ? | |||||
exec {'active-initialize': | |||||
command => "touch ${upgrade_flag_path}", | |||||
path => '/usr/bin', | |||||
refreshonly => true, | |||||
} ~> | |||||
exec {'hedgedoc-flag-upgrade': | |||||
command => "$install_path/bin/setup", | |||||
cwd => $install_path, | |||||
require => Postgresql::Server::Db[$db_name], | |||||
refreshonly => true, | |||||
} ~> | |||||
file {$sequelizerc_config_json_path: | |||||
ensure => present, | |||||
owner => $user, | |||||
group => $group, | |||||
mode => '0644', | |||||
content => template("profile/hedgedoc/config.json.erb"), | |||||
} ~> | |||||
file {$sequelizerc_config_sequelizerc_path: | |||||
Done Inline Actionsthis chaineds exec should all be refreshonly, you have no guaranty on the execution order as there is no strict dependencies between them vsellier: this chaineds exec should all be refreshonly, you have no guaranty on the execution order as… | |||||
ensure => present, | |||||
owner => $user, | |||||
group => $group, | |||||
mode => '0644', | |||||
content => template("profile/hedgedoc/sequelizerc.erb"), | |||||
} ~> | |||||
exec {'yarn-build': | |||||
command => "yarn run build", | |||||
cwd => $install_path, | |||||
path => '/usr/bin', | |||||
onlyif => "test -f ${upgrade_flag_path}", | |||||
refreshonly => true, | |||||
} ~> | |||||
exec {'hegdedoc-flag-upgrade-done': | |||||
command => "rm ${upgrade_flag_path}", | |||||
Done Inline ActionsShould also require the Archive['hedgedoc'] ? vsellier: Should also require the Archive['hedgedoc'] ? | |||||
cwd => $install_path, | |||||
path => '/usr/bin', | |||||
onlyif => "test -f ${upgrade_flag_path}", | |||||
refreshonly => true, | |||||
notify => Service[$service_name], | |||||
} | |||||
systemd::unit_file {$unit_name: | |||||
ensure => present, | |||||
content => template('profile/hedgedoc/hedgedoc.service.erb'), | |||||
} | |||||
service {$service_name: | |||||
ensure => 'running', | |||||
enable => true, | |||||
require => [ | |||||
Systemd::Unit_file[$unit_name], | |||||
Package[$packages], | |||||
Archive['hedgedoc'], | |||||
], | |||||
} | |||||
} |
WDYT about installing the files on /opt/hedgedoc ?