From 3a26c766f92098c6d4bc833fb475217b3846c40e Mon Sep 17 00:00:00 2001 From: Sophie Schiller Date: Sun, 4 Jul 2021 18:04:48 +0200 Subject: [PATCH] bw/bundle matrix-dimension this might actually work --- .../files/matrix-dimension.service | 2 +- bundles/matrix-dimension/files/production.yaml | 2 +- bundles/matrix-dimension/items.py | 14 +++++++++----- bundles/matrix-dimension/metadata.py | 14 +++++--------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bundles/matrix-dimension/files/matrix-dimension.service b/bundles/matrix-dimension/files/matrix-dimension.service index 1b9333f..14b91f4 100644 --- a/bundles/matrix-dimension/files/matrix-dimension.service +++ b/bundles/matrix-dimension/files/matrix-dimension.service @@ -6,7 +6,7 @@ After=network.target User=matrix-support Group=matrix-support Environment="NODE_ENV=production" -ExecStart=/usr/bin/node /opt/matrix/matrix-dimension/build/app/index.js +ExecStart=/usr/bin/node ${config['install_dir']}/build/app/index.js WorkingDirectory=${config['install_dir']} Restart=on-failure diff --git a/bundles/matrix-dimension/files/production.yaml b/bundles/matrix-dimension/files/production.yaml index bb67228..738b1d9 100644 --- a/bundles/matrix-dimension/files/production.yaml +++ b/bundles/matrix-dimension/files/production.yaml @@ -45,7 +45,7 @@ widgetBlacklist: database: # Where the database for Dimension is - uri: "postgres://${node.metadata['matrix-dimension']['database']['user']}:${node.metadata['matrix-dimension']['database']['password']}@${node.metadata['matrix-dimension']['database'].get('host', 'localhost')}/${node.metadata['matrix-dimension']['database']['database']}" + uri: "postgres://${node.metadata['matrix-dimension']['database']['user']}:${node.metadata['matrix-dimension']['database']['password']}@${node.metadata['matrix-dimension']['database'].get('host', 'localhost')}/${node.metadata['matrix-dimension']['database']['database']}" # Where to store misc information for the utility bot account. botData: "${config['data_dir']}/dimension.bot.json" diff --git a/bundles/matrix-dimension/items.py b/bundles/matrix-dimension/items.py index 68375ea..594ba89 100644 --- a/bundles/matrix-dimension/items.py +++ b/bundles/matrix-dimension/items.py @@ -2,8 +2,10 @@ repo.libs.tools.require_bundle(node, 'nodejs') directories = { - node.metadata['matrix-dimension']['install_dir']: {}, - node.metadata['matrix-dimension']['data_dir']: {}, + node.metadata['matrix-dimension']['install_dir']: { + 'owner': 'matrix-support', + 'group': 'matrix-support', + }, } git_deploy = { @@ -22,6 +24,8 @@ git_deploy = { files = { '{}/config/production.yaml'.format(node.metadata['matrix-dimension']['install_dir']): { + 'owner': 'matrix-support', + 'group': 'matrix-support', 'content_type': 'mako', 'context': { 'config': node.metadata.get('matrix-dimension', {}), @@ -44,8 +48,8 @@ files = { } actions = { - 'matrix_dimenson_build': { - 'command': 'cd ' + node.metadata['matrix-dimension']['install_dir'] + ' && npm install && npm run build', + 'matrix_dimension_build': { + 'command': 'cd ' + node.metadata['matrix-dimension']['install_dir'] + ' && sudo -u matrix-support npm install && sudo -u matrix-support npm run build', 'needs': { 'pkg_apt:nodejs', }, @@ -59,7 +63,7 @@ actions = { svc_systemd = { 'matrix-dimension': { 'needs': { - 'action:matrix-dimension_build', + 'action:matrix_dimension_build', 'file:{}/config/production.yaml'.format(node.metadata['matrix-dimension']['install_dir']), 'postgres_db:matrix-dimension', 'postgres_role:matrix-dimension', diff --git a/bundles/matrix-dimension/metadata.py b/bundles/matrix-dimension/metadata.py index 6db7c86..6172b56 100644 --- a/bundles/matrix-dimension/metadata.py +++ b/bundles/matrix-dimension/metadata.py @@ -1,7 +1,7 @@ defaults = { 'matrix-dimension': { 'install_dir': '/opt/matrix-dimension', - 'data_dir': '/var/opt/dimension', + 'data_dir': '/var/opt/matrix-dimension', 'database': { 'user': 'matrix-dimension', 'password': repo.vault.password_for('{} postgresql matrix-dimension'.format(node.name)), @@ -20,13 +20,9 @@ defaults = { }, }, }, - 'icinga2_api': { - 'mautrix-telegram': { - 'services': { - 'MAUTRIX-TELEGRAM PROCESS': { - 'command_on_monitored_host': '/usr/lib/nagios/plugins/check_procs -a mautrix-telegram -c 1:', - }, - }, + 'users': { + 'matrix-support': { + 'home': '/var/opt/matrix-dimension', }, }, } @@ -39,7 +35,7 @@ def nginx_config(metadata): 'nginx': { 'vhosts': { metadata.get('matrix-dimension/url'): { - 'webroot': '/var/www/{}/webapp/'.format(metadata.get('element-web/url')), + 'webroot': '/var/www/{}/webapp/'.format(metadata.get('matrix-dimension/url')), 'do_not_set_content_security_headers': True, 'max_body_size': '50M', 'proxy': {