From 75d0043578478d4a7b41d2052e5874e7702a663e Mon Sep 17 00:00:00 2001 From: mwiegand Date: Fri, 22 Oct 2021 16:06:42 +0200 Subject: [PATCH] multiredis --- bundles/nextcloud/files/managed.config.php | 7 +++++++ bundles/nextcloud/metadata.py | 3 +++ bundles/redis/items.py | 4 +++- bundles/redis/metadata.py | 9 ++++++--- bundles/rspamd/files/local.d/redis.conf | 2 +- bundles/rspamd/metadata.py | 3 +++ nodes/netcup.secondary.py | 6 ------ 7 files changed, 23 insertions(+), 11 deletions(-) diff --git a/bundles/nextcloud/files/managed.config.php b/bundles/nextcloud/files/managed.config.php index 3e50c94..8877d48 100644 --- a/bundles/nextcloud/files/managed.config.php +++ b/bundles/nextcloud/files/managed.config.php @@ -25,4 +25,11 @@ $CONFIG = array ( "memcache.local" => "\\OC\\Memcache\\Redis", "memcache.locking" => "\\OC\\Memcache\\Redis", "memcache.distributed" => "\OC\Memcache\Redis", + "redis" => [ + "host" => "/var/run/redis-nextcloud/redis.sock", + "port" => 0, + "dbindex" => 0, + "password" => "secret", + "timeout" => 1.5, + ], ); diff --git a/bundles/nextcloud/metadata.py b/bundles/nextcloud/metadata.py index 49ad2ba..2be5eb9 100644 --- a/bundles/nextcloud/metadata.py +++ b/bundles/nextcloud/metadata.py @@ -52,6 +52,9 @@ defaults = { }, }, }, + 'redis': { + 'nextcloud': {}, + }, 'systemd-timers': { 'nextcloud-cron': { 'command': '/usr/bin/sudo -u www-data /usr/bin/php -f /opt/nextcloud/cron.php', diff --git a/bundles/redis/items.py b/bundles/redis/items.py index e557d09..25cf083 100644 --- a/bundles/redis/items.py +++ b/bundles/redis/items.py @@ -35,7 +35,9 @@ svc_systemd = { for name, conf in node.metadata.get('redis').items(): files[f'/etc/redis/{name}.conf'] = { 'content': '\n'.join( - f'{key} {value}' for key, value in sorted(conf.items()) + f'{key} {value}' + for key, value in sorted(conf.items()) + if value is not False ), 'owner': 'redis', 'triggers': [ diff --git a/bundles/redis/metadata.py b/bundles/redis/metadata.py index 702ff51..648906a 100644 --- a/bundles/redis/metadata.py +++ b/bundles/redis/metadata.py @@ -10,7 +10,9 @@ defaults = { }, }, 'redis': { - 'server': {}, + 'server': { + 'port': '6379', + }, }, } @@ -38,10 +40,10 @@ def config(metadata): redis[name] = { 'bind': '127.0.0.1 ::1', 'protected-mode': 'yes', - 'port': '6379', + 'port': '0', 'tcp-backlog': '511', 'unixsocket': f'/var/run/redis-{name}/redis.sock', - 'unixsocketperm': '700', + 'unixsocketperm': '777', 'timeout': '0', 'tcp-keepalive': '300', 'daemonize': 'yes', @@ -100,6 +102,7 @@ def config(metadata): 'dynamic-hz': 'yes', 'aof-rewrite-incremental-fsync': 'yes', 'rdb-save-incremental-fsync': 'yes', + **metadata.get(f'redis/{name}', {}), } return { diff --git a/bundles/rspamd/files/local.d/redis.conf b/bundles/rspamd/files/local.d/redis.conf index 5a9c582..d35aabf 100644 --- a/bundles/rspamd/files/local.d/redis.conf +++ b/bundles/rspamd/files/local.d/redis.conf @@ -1 +1 @@ -servers = "127.0.0.1"; +servers = "/var/run/redis-rspamd/redis.sock"; diff --git a/bundles/rspamd/metadata.py b/bundles/rspamd/metadata.py index 3614bc6..48b8de7 100644 --- a/bundles/rspamd/metadata.py +++ b/bundles/rspamd/metadata.py @@ -10,6 +10,9 @@ defaults = { 'rspamd': {}, }, }, + 'redis': { + 'rspamd': {}, + }, 'rspamd': { 'web_password': repo.vault.password_for(node.name + ' rspamd web password'), 'ip_whitelist': set(), diff --git a/nodes/netcup.secondary.py b/nodes/netcup.secondary.py index 2a48bb1..313c6e3 100644 --- a/nodes/netcup.secondary.py +++ b/nodes/netcup.secondary.py @@ -7,7 +7,6 @@ ], 'bundles': [ 'wireguard', - 'redis', ], 'metadata': { 'id': '890848b2-a900-4f74-ad5b-b811fbb4f0bc', @@ -28,11 +27,6 @@ 'master_node': 'htz.mails', 'hostname': 'second.resolver.name', }, - 'redis': { - 'nextcloud': { - 'port': '6380', - }, - }, # 'postfix': { # 'master_node': 'htz.mails', # 'hostname': 'mail2.sublimity.de',