From bf125a73b11d641b2716ae620f5863666ecc5e1f Mon Sep 17 00:00:00 2001 From: Sophie Schiller Date: Thu, 23 Dec 2021 13:48:44 +0100 Subject: [PATCH] infobeamer-cms: initial commit --- bundles/infobeamer-cms/files/settings.cfg | 47 +++++++++++++ bundles/infobeamer-cms/items.py | 57 +++++++++++++++ bundles/infobeamer-cms/metadata.py | 86 +++++++++++++++++++++++ nodes/voc/infobeamer-cms.py | 43 ++++++++++++ 4 files changed, 233 insertions(+) create mode 100644 bundles/infobeamer-cms/files/settings.cfg create mode 100644 bundles/infobeamer-cms/items.py create mode 100644 bundles/infobeamer-cms/metadata.py create mode 100644 nodes/voc/infobeamer-cms.py diff --git a/bundles/infobeamer-cms/files/settings.cfg b/bundles/infobeamer-cms/files/settings.cfg new file mode 100644 index 0000000..a0deee5 --- /dev/null +++ b/bundles/infobeamer-cms/files/settings.cfg @@ -0,0 +1,47 @@ +<% +from json import dumps +%> +# This github OAuth client will be used for authentication. Create +# one at https://github.com/organizations/ACCOUNT/settings/applications +GITHUB_CLIENT_ID = '${GITHUB_CLIENT_ID}' +GITHUB_CLIENT_SECRET = '${GITHUB_CLIENT_SECRET}' + +SESSION_COOKIE_NAME = '${SESSION_COOKIE_NAME}' + +PREFERRED_URL_SCHEME = '${PREFERRED_URL_SCHEME}' + +# info-beamer API keys. +# This key needs access to setups and assets as well as the +# node-message calls. If you consider the host running this +# code trusted, you might use a key with full account access. +# The keys given out to users are adhoc keys based on this key. +HOSTED_API_KEY = '${HOSTED_API_KEY}' + +# Maximum uploads per github user +MAX_UPLOADS = ${MAX_UPLOADS} + +# Setup IDs using the scheduled player setup. One of the +# playlists must be named 'User Content'. Its pages will be +# autogenerated by the CMS when calling /sync +SETUP_IDS = ${SETUP_IDS} + +# Generate some random string. It's used for signing +# urls send to moderators. +URL_KEY = '${URL_KEY}' + +# Push notifications for moderation requests user pushover. +# Specify a target key and the app key to use. +PUSHOVER_TARGET = '${PUSHOVER_TARGET}' +PUSHOVER_APP_KEY = '${PUSHOVER_APP_KEY}' + +# Unix timestamp allows for specifying start/end time +# of uploaded content +TIME_MIN = ${TIME_MIN} +TIME_MAX = ${TIME_MAX} + +# change this to invalidate cached static files. +VERSION = ${VERSION} + +# rooms. This is both used for the /last view as well +# as the interruption control on /interrupt. +ROOMS = ${dumps(node.metadata.get('infobeamer-cms/config/ROOMS', {}))} diff --git a/bundles/infobeamer-cms/items.py b/bundles/infobeamer-cms/items.py new file mode 100644 index 0000000..7b572bb --- /dev/null +++ b/bundles/infobeamer-cms/items.py @@ -0,0 +1,57 @@ +git_deploy = { + '/opt/infobeamer-cms': { + 'rev': 'MASTER', + 'repo': 'https://github.com/sophieschi/36c3-cms.git', + 'needs': { + 'directory:/opt/infobeamer-cms', + }, + 'triggers': { + 'svc_systemd:infobeamer-cms:restart', + }, + }, +} + +directories = { + '/opt/infobeamer-cms': {}, +} + +files = { + '/opt/infobeamer-cms/settings.cfg': { + 'content_type': 'mako', + 'context': node.metadata.get('infobeamer-cms/config'), + 'needs': { + 'git_deploy:/opt/infobeamer-cms', + }, + 'triggers': { + 'svc_systemd:infobeamer-cms:restart', + }, + }, + '/etc/systemd/system/infobeamer-cms.service': { + 'triggers': { + 'action:systemd-reload', + 'svc_systemd:infobeamer-cms:restart', + }, + } +} + +pkg_pip = { + 'github-flask': { + 'needed_by': { + 'git_deploy:/opt/infobeamer-cms', + }, + }, +} + +svc_systemd = { + 'infobeamer-cms': { + 'needs': { + 'file:/opt/infobeamer-cms/settings.cfg', + }, + }, +} + +users = { + 'infobeamer-cms': { + 'home': '/opt/infobeamer-cms', + }, +} diff --git a/bundles/infobeamer-cms/metadata.py b/bundles/infobeamer-cms/metadata.py new file mode 100644 index 0000000..b10e0fb --- /dev/null +++ b/bundles/infobeamer-cms/metadata.py @@ -0,0 +1,86 @@ +defaults = { + 'apt': { + 'packages': { + 'gunicorn': {}, + 'python3-gevent': {}, + 'python3-flask': {}, + 'python3-redis': {}, + 'python3-virtualenv': {}, + 'python3-requests': {}, + 'python3-iso8601': {}, + }, + }, + 'infobeamer-cms': { + 'config': { + 'GITHUB_CLIENT_ID': 'encrypted1', + 'GITHUB_CLIENT_SECRET': 'encryted2', + 'SESSION_COOKIE_NAME': '__Host-sess', + 'PREFERRED_URL_SCHEME': 'https', + 'HOSTED_API_KEY': 'encrypted3', + 'MAX_UPLOADS': 5, + 'SETUP_IDS': '[123456]', + 'URL_KEY': 'encrypted4', + 'PUSHOVER_TARGET': 'encrypted5', + 'PUSHOVER_APP_KEY': 'encrypted6', + 'TIME_MIN': 1640039559, + 'TIME_MAX': 1640905200, + 'VERSION': 1, + 'ROOMS': [ + { + 'name': 'Ada', + 'device_id': 5919, + 'interrupts': [ + { + 'name': 'Signal', + 'data': 'signal', + }, + ], + }, + { + 'name': 'Borg', + 'device_id': 5920, + 'interrupts': [ + { + 'name': 'Signal', + 'data': 'signal', + }, + ], + }, + ], + 'unused': 'foobar', + }, + }, +} + +@metadata_reactor.provides( + 'nginx/vhosts', +) +def nginx(metadata): + if not node.has_bundle('nginx'): + raise DoNotRunAgain + + locations = { + '/': { + 'target': 'http://127.0.0.1:8000', + }, + '/twitter/': { + 'alias': '/export/twitter/', + }, + '/static/': { + 'alias': '/opt/infobeamer-cms/static', + }, + } + + vhosts = { + 'infobeamer-cms': { + 'locations': locations, + 'website_check_path': '/', + 'website_check_string': '', + }, + } + + return { + 'nginx': { + 'vhosts': vhosts + }, + } diff --git a/nodes/voc/infobeamer-cms.py b/nodes/voc/infobeamer-cms.py new file mode 100644 index 0000000..ae0d911 --- /dev/null +++ b/nodes/voc/infobeamer-cms.py @@ -0,0 +1,43 @@ +nodes['voc.infobeamer-cms'] = { + 'hostname': 'pretalx.c3voc.de', + 'bundles': { + 'infobeamer-cms', + 'redis', + }, + 'groups': { + 'debian-buster', + 'webserver', + }, + 'metadata': { + 'apt': { + # Move patchday to somewhere where the possibility of + # clashing with actual events is less likely. + 'unattended_upgrades': { + 'day': 1, + }, + }, + 'backups': { + 'exclude_from_backups': True, + }, + 'interfaces': { + 'default': { + 'ips': { + '31.172.33.106/28', + '2a01:a700:48d1::106/64', + }, + 'gateway4': '31.172.33.110', + 'gateway6': '2a01:a700:48d1::1', + }, + }, + 'icinga_options': { + 'pretty_name': 'infobeamer-cms.c3voc.de', + }, + 'nginx': { + 'vhosts': { + 'infobeamer-cms': { + 'domain': 'infobeamer-cms.c3voc.de', + }, + }, + }, + }, +}