From d9cb324bb64feeb70579ce7f77351e4e7d0857ab Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 9 Sep 2023 17:48:22 +0200 Subject: [PATCH] update pretalx to 2023.1.0 --- bundles/c3voc-addons/items.py | 49 ++++++++++++++++++++++++++ bundles/pretalx/items.py | 49 ++++++++++++++------------ bundles/pretalx/metadata.py | 8 +++-- data/c3voc-addons/files | 1 - data/c3voc-addons/files/error.html | 1 + data/c3voc-addons/files/extras | 1 + data/c3voc-addons/files/gpg-keys | 1 + data/c3voc-addons/files/not_found.html | 1 + data/c3voc-addons/files/ssl | 1 + nodes/voc/pretalx.py | 11 ++++-- 10 files changed, 93 insertions(+), 30 deletions(-) delete mode 120000 data/c3voc-addons/files create mode 120000 data/c3voc-addons/files/error.html create mode 120000 data/c3voc-addons/files/extras create mode 120000 data/c3voc-addons/files/gpg-keys create mode 120000 data/c3voc-addons/files/not_found.html create mode 120000 data/c3voc-addons/files/ssl diff --git a/bundles/c3voc-addons/items.py b/bundles/c3voc-addons/items.py index a8116a2..709b10e 100644 --- a/bundles/c3voc-addons/items.py +++ b/bundles/c3voc-addons/items.py @@ -1,5 +1,22 @@ from bundlewrap.exceptions import BundleError +supported_os = { + 'debian': { + 10: 'buster', + 11: 'bullseye', + 12: 'bookworm', + 99: 'unstable', + }, + 'raspbian': { + 10: 'buster', + }, +} + +try: + supported_os[node.os][node.os_version[0]] +except (KeyError, IndexError): + raise BundleError(f'{node.name}: OS {node.os} {node.os_version} is not supported by bundle:apt') + CONFLICTING_BUNDLES = { 'apt', 'nginx', @@ -57,6 +74,14 @@ actions = { 'svc_systemd:', }, }, + 'apt_update': { + 'command': 'apt-get update', + 'needed_by': { + 'pkg_apt:', + }, + 'triggered': True, + 'cascade_skip': False, + }, } directories = { @@ -92,6 +117,30 @@ files = { }, } +for name, data in node.metadata.get('apt/repos', {}).items(): + files['/etc/apt/sources.list.d/{}.list'.format(name)] = { + 'content_type': 'mako', + 'content': ("\n".join(sorted(data['items']))).format( + os=node.os, + os_release=supported_os[node.os][node.os_version[0]], + ), + 'triggers': { + 'action:apt_update', + }, + } + + if data.get('install_gpg_key', True): + files['/etc/apt/sources.list.d/{}.list'.format(name)]['needs'] = { + 'file:/etc/apt/trusted.gpg.d/{}.list.asc'.format(name), + } + + files['/etc/apt/trusted.gpg.d/{}.list.asc'.format(name)] = { + 'source': 'gpg-keys/{}.asc'.format(name), + 'triggers': { + 'action:apt_update', + }, + } + for crontab, content in node.metadata.get('cron/jobs', {}).items(): files['/etc/cron.d/{}'.format(crontab)] = { 'source': 'cron_template', diff --git a/bundles/pretalx/items.py b/bundles/pretalx/items.py index e5b65d1..8a57eae 100644 --- a/bundles/pretalx/items.py +++ b/bundles/pretalx/items.py @@ -1,3 +1,6 @@ +assert node.has_bundle('redis'), f'{node.name}: pretalx needs redis' +assert node.has_bundle('nodejs'), f'{node.name}: pretalx needs nodejs for rebuild and regenerate_css step' + actions = { 'pretalx_create_virtualenv': { 'command': '/usr/bin/python3 -m virtualenv -p python3 /opt/pretalx/venv/', @@ -8,17 +11,20 @@ actions = { }, }, 'pretalx_install': { - 'command': - 'cd /opt/pretalx/src/src && ' - '/opt/pretalx/venv/bin/pip install --upgrade pip wheel gunicorn psycopg2-binary && ' + 'command': ' && '.join([ + 'cd /opt/pretalx/src', + '/opt/pretalx/venv/bin/pip install --upgrade pip wheel gunicorn psycopg2-binary', '/opt/pretalx/venv/bin/pip install --upgrade -e .[redis]', + ]), 'needs': { 'action:pretalx_create_virtualenv', + 'pkg_apt:gcc', + 'pkg_apt:python3-dev', }, 'triggered': True, }, 'pretalx_migrate': { - 'command': 'PRETALX_CONFIG_FILE=/opt/pretalx/pretalx.cfg /opt/pretalx/venv/bin/python -m pretalx migrate', + 'command': '/usr/bin/sudo -Hu pretalx PRETALX_CONFIG_FILE=/opt/pretalx/pretalx.cfg /opt/pretalx/venv/bin/python -m pretalx migrate', 'needs': { 'action:pretalx_install', 'file:/opt/pretalx/pretalx.cfg', @@ -28,24 +34,33 @@ actions = { 'triggered': True, }, 'pretalx_rebuild': { - 'command': 'PRETALX_CONFIG_FILE=/opt/pretalx/pretalx.cfg /opt/pretalx/venv/bin/python -m pretalx rebuild', + 'command': ' && '.join([ + 'cd /opt/pretalx/src/src/pretalx/frontend/schedule-editor/', + 'npm install', + 'PRETALX_CONFIG_FILE=/opt/pretalx/pretalx.cfg /opt/pretalx/venv/bin/python -m pretalx rebuild', + ]), 'needs': { 'action:pretalx_install', 'action:pretalx_migrate', 'directory:/opt/pretalx/data', 'directory:/opt/pretalx/static', 'file:/opt/pretalx/pretalx.cfg', + 'bundle:nodejs', + }, + 'triggers': { + # pretalx-web reads the manifest.json generated by this build-step upon startup + 'svc_systemd:pretalx-web:restart', }, 'triggered': True, }, 'pretalx_regenerate-css': { 'command': 'sudo -u pretalx PRETALX_CONFIG_FILE=/opt/pretalx/pretalx.cfg /opt/pretalx/venv/bin/python -m pretalx regenerate_css', 'needs': { - 'action:pretalx_install', 'action:pretalx_migrate', 'directory:/opt/pretalx/data', 'directory:/opt/pretalx/static', 'file:/opt/pretalx/pretalx.cfg', + 'bundle:nodejs', }, 'triggered': True, }, @@ -70,7 +85,7 @@ directories = { git_deploy = { '/opt/pretalx/src': { 'repo': 'https://github.com/pretalx/pretalx.git', - 'rev': node.metadata['pretalx']['version'], + 'rev': node.metadata.get('pretalx/version'), 'triggers': { 'action:pretalx_install', 'action:pretalx_migrate', @@ -82,7 +97,6 @@ git_deploy = { }, } - svc_systemd = { 'pretalx-runperiodic.timer': { 'needs': { @@ -125,15 +139,12 @@ svc_systemd = { files = { '/opt/pretalx/pretalx.cfg': { 'content_type': 'mako', - 'context': node.metadata['pretalx'], + 'context': node.metadata.get('pretalx'), 'triggers': { 'svc_systemd:pretalx-web:restart', 'svc_systemd:pretalx-worker:restart', }, }, - '/opt/pretalx/pretalx-administrators-from-group': { - 'mode': '0755', - }, '/etc/systemd/system/pretalx-runperiodic.timer': { 'triggers': { 'action:systemd-reload', @@ -170,24 +181,16 @@ files = { }, } -if node.metadata.get('pretalx/administrators-from-group-id', None): - files['/etc/cron.d/pretalx-administrators-from-group'] = { - 'source': 'cron-pretalx-administrators-from-group', - 'content_type': 'mako', - } -else: - files['/etc/cron.d/pretalx-administrators-from-group'] = { - 'delete': True, - } - # run `pip install` one after another due to concurrency issues last_action = 'action:pretalx_install' for plugin_name, plugin_config in node.metadata.get('pretalx/plugins', {}).items(): + assert '-' not in plugin_name, f'{node.name} pretalx plugin {plugin_name} must not contain dashes' + directories[f'/opt/pretalx/plugin_{plugin_name}'] = {} git_deploy[f'/opt/pretalx/plugin_{plugin_name}'] = { 'repo': plugin_config['repo'], - 'rev': plugin_config['rev'], + 'rev': plugin_config.get('rev', 'master'), 'triggers': { f'action:pretalx_install_plugin_{plugin_name}', }, diff --git a/bundles/pretalx/metadata.py b/bundles/pretalx/metadata.py index 3c52e15..f60c54b 100644 --- a/bundles/pretalx/metadata.py +++ b/bundles/pretalx/metadata.py @@ -1,17 +1,19 @@ defaults = { 'apt': { 'packages': { + 'gcc': {}, # for compiling some python deps 'gettext': {}, + 'python3-dev': {}, }, }, + 'bash_aliases': { + 'pretalx': 'sudo /opt/pretalx/venv/bin/python -m pretalx', + }, 'backups': { 'paths': { '/opt/pretalx/data', }, }, - 'bash_aliases': { - 'pretalx': 'sudo /opt/pretalx/venv/bin/python -m pretalx', - }, 'icinga2_api': { 'pretalx': { 'services': { diff --git a/data/c3voc-addons/files b/data/c3voc-addons/files deleted file mode 120000 index e2f9229..0000000 --- a/data/c3voc-addons/files +++ /dev/null @@ -1 +0,0 @@ -../nginx/files \ No newline at end of file diff --git a/data/c3voc-addons/files/error.html b/data/c3voc-addons/files/error.html new file mode 120000 index 0000000..26606f0 --- /dev/null +++ b/data/c3voc-addons/files/error.html @@ -0,0 +1 @@ +../../nginx/files/error.html \ No newline at end of file diff --git a/data/c3voc-addons/files/extras b/data/c3voc-addons/files/extras new file mode 120000 index 0000000..afe5648 --- /dev/null +++ b/data/c3voc-addons/files/extras @@ -0,0 +1 @@ +../../nginx/files/extras \ No newline at end of file diff --git a/data/c3voc-addons/files/gpg-keys b/data/c3voc-addons/files/gpg-keys new file mode 120000 index 0000000..c649d44 --- /dev/null +++ b/data/c3voc-addons/files/gpg-keys @@ -0,0 +1 @@ +../../apt/files/gpg-keys \ No newline at end of file diff --git a/data/c3voc-addons/files/not_found.html b/data/c3voc-addons/files/not_found.html new file mode 120000 index 0000000..b6964cb --- /dev/null +++ b/data/c3voc-addons/files/not_found.html @@ -0,0 +1 @@ +../../nginx/files/not_found.html \ No newline at end of file diff --git a/data/c3voc-addons/files/ssl b/data/c3voc-addons/files/ssl new file mode 120000 index 0000000..348aeea --- /dev/null +++ b/data/c3voc-addons/files/ssl @@ -0,0 +1 @@ +../../ssl \ No newline at end of file diff --git a/nodes/voc/pretalx.py b/nodes/voc/pretalx.py index 86f2f68..4c877a9 100644 --- a/nodes/voc/pretalx.py +++ b/nodes/voc/pretalx.py @@ -8,6 +8,7 @@ nodes['voc.pretalx'] = { 'backup-client', 'check-mail-received', 'c3voc-addons', + 'nodejs', 'pretalx', 'postfix', 'postgresql', @@ -48,17 +49,21 @@ nodes['voc.pretalx'] = { }, }, 'pretalx': { - 'version': '60722c43cf975f319e94102e6bff320723776890', + 'version': 'v2023.1.0', 'domain': 'pretalx.c3voc.de', 'mail_from': 'pretalx@c3voc.de', 'administrators-from-group-id': 1, 'plugins': { + 'broadcast_tools': { + 'repo': 'https://github.com/Kunsi/pretalx-plugin-broadcast-tools.git', + 'rev': '2.0.1', + }, 'downstream': { 'repo': 'https://github.com/pretalx/pretalx-downstream.git', 'rev': 'v1.1.5', }, - 'broadcast_tools': { - 'repo': 'https://github.com/Kunsi/pretalx-plugin-broadcast-tools.git', + 'halfnarp': { + 'repo': 'https://github.com/seibert-media/pretalx-halfnarp.git', 'rev': '1.1.0', }, 'media.ccc.de': {