From 79e10b9b3584389e1d5238e38dd184652edc0575 Mon Sep 17 00:00:00 2001 From: phil Date: Sat, 7 Aug 2021 16:45:32 +0200 Subject: [PATCH] Konfiguriere Redis-DB pro Instanz --- defaults/main.yml | 3 +- tasks/nextcloud.yml | 69 --------------------------------------------- tasks/redis.yml | 15 ++++++++-- 3 files changed, 15 insertions(+), 72 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 60e67b3..56092f3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -12,7 +12,7 @@ nextcloud_php_memory_limit: 512M nextcloud_php_upload_limit: 512M nextcloud_trusted_domains: ['localhost', '{{ instance.domain }}'] nextcloud_trusted_proxies: ['10.42.7.1'] -nextcloud_version: nextcloud-21.0.2 +nextcloud_version: nextcloud-21.0.3 nextcloud_mail_from: noreply nextcloud_mail_domain: postfach.senselab.org nextcloud_smtp_auth_type: LOGIN @@ -20,3 +20,4 @@ nextcloud_smtp_host: sl-postbote.kahlo nextcloud_smtp_port: 25 php_version: "7.3" +redis_config_file: /etc/redis/redis.conf diff --git a/tasks/nextcloud.yml b/tasks/nextcloud.yml index 83ef6c1..a0dd05b 100644 --- a/tasks/nextcloud.yml +++ b/tasks/nextcloud.yml @@ -25,72 +25,3 @@ become: true become_user: "{{ instance.user }}" changed_when: true - -#todo: Auch auf instances.alias anwenden -- name: "nextcloud: {{ instance.domain }}: trusted domains einrichten" - command: 'php {{ nextcloud_install_path }}/occ config:system:set trusted_domains {{ item.0 }} --value "{{ item.1 }}"' - become: true - become_user: "{{ instance.user }}" - changed_when: true - with_indexed_items: - - '{{ nextcloud_trusted_domains }}' - -- name: "nextcloud: {{ instance.domain }}: cron einrichten" - cron: - name: "nextcloud {{ instance.domain }}" - minute: "*/5" - user: "{{ instance.user }}" - job: "php -f {{ nextcloud_install_path}}/cron.php" - cron_file: "nextcloud" - -- name: "nextcloud: {{ instance.domain }}: allgemeie Konfiguration" - command: "{{ item }}" - become: true - become_user: "{{ instance.user }}" - changed_when: true - with_items: - - 'php {{ nextcloud_install_path }}/occ config:system:set memcache.local --value "\\OC\\Memcache\\APCu"' - - 'php {{ nextcloud_install_path }}/occ config:system:set memcache.distributed --value "\OC\Memcache\Redis"' - - "php {{ nextcloud_install_path }}/occ background:cron" - - 'php {{ nextcloud_install_path }}/occ config:system:set overwrite.cli.url --value https://{{ instance.domain }}' - - 'php {{ nextcloud_install_path }}/occ config:system:set htaccess.RewriteBase --value /' - - 'php {{ nextcloud_install_path }}/occ maintenance:update:htaccess' - - 'php {{ nextcloud_install_path }}/occ config:system:set default_language --value "de"' - - 'php {{ nextcloud_install_path }}/occ config:system:set default_phone_region --value "DE"' - - 'php {{ nextcloud_install_path }}/occ config:system:set loglevel --value "1"' - -- name: "nextcloud: {{ instance.domain }}: Mailversand einrichten" - blockinfile: - path: "{{ nextcloud_config_file }}" - insertbefore: '^\);' - marker_begin: mailserver - block: |2 - 'mail_from_address' => '{{ nextcloud_mail_from }}', - 'mail_smtpmode' => 'smtp', - 'mail_sendmailmode' => 'smtp', - 'mail_domain' => '{{ nextcloud_mail_domain }}', - 'mail_smtpauthtype' => '{{ nextcloud_smtp_auth_type }}', - 'mail_smtphost' => '{{ nextcloud_smtp_host }}', - 'mail_smtpport' => '{{ nextcloud_smtp_port}}', - -- name: "nextcloud: {{ instance.domain }}: Filelocking" - blockinfile: - path: "{{ nextcloud_config_file }}" - insertbefore: '^\);' - marker_begin: filelocking - block: |2 - 'filelocking.enabled' => true, - 'memcache.locking' => '\OC\Memcache\Redis', - 'redis' => array( - 'host' => '/var/run/redis/redis-server.sock', - 'port' => 0, - 'timeout' => 0.0, - ), - -- name: "nextcloud: {{ instance.domain }}: trusted proxies einrichten" - command: 'php {{ nextcloud_install_path }}/occ config:system:set trusted_proxies {{ item.0 }} --value "{{ item.1 }}"' - become: true - become_user: "{{ instance.user }}" - changed_when: true - with_indexed_items: - - '{{ nextcloud_trusted_proxies }}' diff --git a/tasks/redis.yml b/tasks/redis.yml index 8d82017..52b0caf 100644 --- a/tasks/redis.yml +++ b/tasks/redis.yml @@ -1,12 +1,23 @@ --- - name: "redis: Aktiviere Socket" lineinfile: - path: /etc/redis/redis.conf + path: "{{ redis_config_file }}" regexp: '^# unixsocket /var/run/redis/redis-server.sock' line: 'unixsocket /var/run/redis/redis-server.sock' - name: "redis: Socket-Berechtigungen stetzen" lineinfile: - path: /etc/redis/redis.conf + path: "{{ redis_config_file }}" regexp: '^# unixsocketperm 700' line: 'unixsocketperm 770' + +- name: "redis: Ermittle Anzahl der NC-Instanzen" + set_fact: + instances_number: "{{ instances | length }}" + +- name: "redis: Konfiguriere Anzahl der Datenbanken" + lineinfile: + path: "{{ redis_config_file }}" + regexp: '^databases 16$' + line: 'databases {{ instances_number }}' + when: instances_number <= 16