From 0784b85fbbb5e2463be7094ba677ac25c5a15d0d Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 26 Sep 2020 15:34:12 +0200 Subject: [PATCH] bundles/mx-puppet-discord: create registration.yaml using bw --- .../mx-puppet-discord/files/registration.yaml | 15 ++++++++++ bundles/mx-puppet-discord/items.py | 29 ++++++++++--------- bundles/mx-puppet-discord/metadata.py | 3 ++ 3 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 bundles/mx-puppet-discord/files/registration.yaml diff --git a/bundles/mx-puppet-discord/files/registration.yaml b/bundles/mx-puppet-discord/files/registration.yaml new file mode 100644 index 0000000..d008ff7 --- /dev/null +++ b/bundles/mx-puppet-discord/files/registration.yaml @@ -0,0 +1,15 @@ +as_token: ${node.metadata['mx-puppet-discord']['as_token']} +hs_token: ${node.metadata['mx-puppet-discord']['hs_token']} +id: discord-puppet +namespaces: + users: + - exclusive: true + regex: '@_discordpuppet_.*' + rooms: [] + aliases: + - exclusive: true + regex: '#_discordpuppet_.*' +protocols: [] +rate_limited: false +sender_localpart: ${node.metadata['mx-puppet-discord']['sender_localpart']} +url: 'http://${node.metadata['mx-puppet-discord'].get('listen-addr', '127.0.0.1')}:${node.metadata['mx-puppet-discord'].get('port', 20000)}' diff --git a/bundles/mx-puppet-discord/items.py b/bundles/mx-puppet-discord/items.py index 71d105a..728363a 100644 --- a/bundles/mx-puppet-discord/items.py +++ b/bundles/mx-puppet-discord/items.py @@ -15,7 +15,17 @@ files = { 'action:mx-puppet-discord_chown', }, 'triggers': { - 'action:mx-puppet-discord_generate_registration', + 'svc_systemd:mx-puppet-discord:restart', + }, + }, + '/opt/mx-puppet-discord/registration.yaml': { + 'owner': 'mx-puppet-discord', + 'content_type': 'mako', + 'needs': { + 'git_deploy:/opt/mx-puppet-discord', + 'action:mx-puppet-discord_chown', + }, + 'triggers': { 'svc_systemd:mx-puppet-discord:restart', }, }, @@ -62,27 +72,18 @@ actions = { }, 'triggered': True, }, - 'mx-puppet-discord_generate_registration': { - 'command': 'cd /opt/mx-puppet-discord && $(rm /opt/mx-puppet-discord/registration.yaml || true) && sudo -u mx-puppet-discord node ./build/index.js -r -c /opt/mx-puppet-discord/config.yaml -f /opt/mx-puppet-discord/registration.yaml', - 'needs': { - 'user:mx-puppet-discord', - 'action:mx-puppet-discord_npm_build', - 'directory:/var/log/mx-puppet-discord', - }, - 'triggers': { - 'svc_systemd:mx-puppet-discord:restart', - }, - 'triggered': True, - }, } svc_systemd = { 'mx-puppet-discord': { 'needs': { + 'action:mx-puppet-discord_npm_build', 'file:/etc/systemd/system/mx-puppet-discord.service', + 'file:/opt/mx-puppet-discord/config.yaml', + 'file:/opt/mx-puppet-discord/registration.yaml', }, }, } if node.has_bundle('matrix-synapse'): - actions['mx-puppet-discord_generate_registration']['triggers'].add('svc_systemd:matrix-synapse:restart') + files['/opt/mx-puppet-discord/registration.yaml']['triggers'].add('svc_systemd:matrix-synapse:restart') diff --git a/bundles/mx-puppet-discord/metadata.py b/bundles/mx-puppet-discord/metadata.py index e31a745..c7e809d 100644 --- a/bundles/mx-puppet-discord/metadata.py +++ b/bundles/mx-puppet-discord/metadata.py @@ -16,6 +16,9 @@ defaults = { 'password': repo.vault.password_for('{} postgresql mx-puppet-discord'.format(node.name)), 'database': 'mx-puppet-discord', }, + 'as_token': repo.vault.password_for('{} mx-puppet-discord as_token'.format(node.name)), + 'hs_token': repo.vault.password_for('{} mx-puppet-discord hs_token'.format(node.name)), + 'sender_localpart': '_discordpuppet_bot', }, 'postgresql': { 'users': {