nierdz.nextcloud

CI-Status Ansible-Rolle Ansible-Qualitätsbewertung Ansible-Rolle Lizenz: GPL v3

Nextcloud

Diese Ansible-Rolle installiert Nextcloud auf die Capistrano-Art. Das bedeutet, die Ordnerstruktur sieht so aus:

/var/wwww
└── nextcloud.local
    ├── current -> /var/www/nextcloud.local/releases/20.0.7
    │   └── nextcloud
    │       └── config
    │          └── config.php -> /var/www/shared/config.php
    ├── data
    │   ├── admin
    │   ├── appdata_somerandomshit
    │   ├── files_external
    │   ├── index.html
    │   └── nextcloud.log
    ├── releases
    │   ├── 20.0.5
    │   ├── 20.0.6
    │   └── 20.0.7
    └── shared
        └── config.php

Aktuell unterstützt diese Rolle nur MySQL als Backend. Es verwendet Redis mit der Standardkonfiguration für lokale und verteilte Caching sowie transaktionales Dateisperren.

Anforderungen

Nextcloud benötigt PHP, einen Webserver und ein DBMS, um zu funktionieren. Um diese Anforderungen zu erfüllen, wird dringend empfohlen, diese 3 Rollen zu verwenden:

Warum gerade diese Rollen? Weil sie gut gewartet werden und einige Variablen aus diesen Rollen in dieser verwendet werden, aber man kann auch andere Rollen nutzen.

In der Produktion benötigen Sie außerdem ein TLS-Zertifikat, das Sie mit acme.sh erhalten können.

Rollenvariablen

nextcloud_version

Version von Nextcloud, die installiert werden soll. Standard: "29.0.1"

nextcloud_domain

Zu verwendender Domainname. Standard: ""

nextcloud_php_user

Alle Nextcloud-Dateien gehören diesem Benutzer. Normalerweise müssen Sie diesen Wert auf www-data setzen. Standard: "{{ php_fpm_pool_user | default('www-data') }}"

nextcloud_php_version

Hauptversion von PHP, die verwendet werden soll. Standard: "{{ php_default_version_debian | default('8.2') }}"

nextcloud_php_bin_path

Pfad zur PHP-Binärdatei. Standard: /usr/bin/php

nextcloud_keep_releases

Wie lange alte Versionen aufbewahrt werden sollen. Standard: "60d"

nextcloud_admin_user

Standard-Admin-Benutzer, der während der Installation erstellt wird. Sobald die Installation abgeschlossen ist, können Sie einen anderen Benutzer mit Admin-Rechten erstellen und diesen entfernen. Standard: ""

nextcloud_admin_password

Passwort des nextcloud_admin_user. Es wird dringend empfohlen, dies mit ansible-vault zu verwahren. Standard: ""

nextcloud_config_template

Jinja2-Vorlage, die für Nextclouds config.php verwendet wird. Um eine benutzerdefinierte Konfigurationsvorlage zu verwenden, müssen Sie:

  • ein Verzeichnis templates/ auf derselben Ebene wie Ihr Playbook erstellen
  • eine Datei templates/myconfig.php.j2 erstellen (wählen Sie einfach einen anderen Namen als die Standardvorlage)
  • in Ihrem Playbook die Variable nextcloud_config_template: myconfig.php.j2 setzen. Standard: "config.php.j2"

nextcloud_instanceid

Eindeutige Instanz-ID. Generieren Sie eine zufällige und behalten Sie diese, solange Ihre Installation aktiv ist. Standard: ""

nextcloud_passwordsalt

Das Salt, das zum Hashen aller Passwörter verwendet wird. Es wird dringend empfohlen, dies mit ansible-vault zu verwahren. Standard: ""

nextcloud_secret

Geheimnis, das von Nextcloud für verschiedene Zwecke verwendet wird, z. B. zur Verschlüsselung von Daten. Wenn Sie diesen String verlieren, kommt es zu Datenbeschädigungen. Es wird dringend empfohlen, dies mit ansible-vault zu verwahren. Standard: ""

nextcloud_dbhost

Host, der zur Verbindung mit der Datenbank verwendet wird. Standard: "localhost"

nextcloud_dbname

Der Name der Nextcloud-Datenbank, die während der Installation festgelegt wird. Standard: "nextcloud"

nextcloud_dbuser

Der Benutzer, den Nextcloud zum Lesen und Schreiben in der Datenbank verwendet. Standard: "nextcloud"

nextcloud_dbpassword

Passwort des nextcloud_dbuser. Es wird dringend empfohlen, dies mit ansible-vault zu verwahren. Standard: ""

nextcloud_deploy_to

Hauptverzeichnis Ihrer Nextcloud-Installation. Standard: "/var/www/{{ nextcloud_domain }}"

nextcloud_datadirectory

Wo Benutzerdateien gespeichert werden. Standard: "{{ nextcloud_deploy_to }}/data"

nextcloud_php_packages

Zusätzliche PHP-Pakete, die Nextcloud benötigt. Standard:

- php-pear
- php{{ nextcloud_php_version }}-bcmath
- php{{ nextcloud_php_version }}-bz2
- php{{ nextcloud_php_version }}-curl
- php{{ nextcloud_php_version }}-gd
- php{{ nextcloud_php_version }}-gmp
- php{{ nextcloud_php_version }}-imagick
- php{{ nextcloud_php_version }}-intl
- php{{ nextcloud_php_version }}-json
- php{{ nextcloud_php_version }}-mbstring
- php{{ nextcloud_php_version }}-mysql
- php{{ nextcloud_php_version }}-redis
- php{{ nextcloud_php_version }}-xml
- php{{ nextcloud_php_version }}-zip

nextcloud_packages

Zusätzliche Pakete, die Nextcloud benötigt. Standard:

- redis-server
- redis-tools
- unzip

nextcloud_apps

Liste der Apps, die installiert und aktiviert werden sollen. Standard: []

nextcloud_no_log

Vertrauliche Daten während der Bereitstellung verbergen. Standard: true

Beispiel

Hier ist, was Sie in Ihrer playbook.yml haben sollten:

- name: Nextcloud-Server konfigurieren
  become: true
  hosts: nextcloud
  vars_files:
    - vault_vars/nextcloud.yml
  roles:
    - {role: acme_sh, tags: [acme_sh]} (nehmen Sie, was immer Sie wollen, um TLS-Zertifikate zu erhalten)
    - {role: nginx, tags: ['nginx']}
    - {role: mysql, tags: ['mysql']}
    - {role: php, tags: ['php']}
    - {role: percona, tags: ['percona']}
    - {role: nextcloud, tags: ['nextcloud']}
  pre_tasks:
    - name: Surystore-Schlüssel installieren
      apt_key:
        url: "https://packages.sury.org/php/apt.gpg"
        state: present
    - name: Sury-Repositories hinzufügen
      apt_repository:
        repo: "deb https://packages.sury.org/php/ {{ ansible_distribution_release }} main"
        state: present
        update_cache: true
        filename: sury
    - name: Bestimmte nginx-Konfigurationsdateien kopieren
      copy:
        src: "{{ item }}"
        dest: /etc/nginx/
        owner: root
        mode: 0644
      with_fileglob:
        - nginx/*.conf
    - name: /etc/nginx/dh4096.pem kopieren
      copy:
        src: nginx/dh4096.pem
        dest: /etc/nginx/dh4096.pem
        owner: www-data
        mode: 0400

Hier sind Ihre verwahrten Variablen in vault_vars/nextcloud.yml:

mysql_root_password_vault: vaultmeplease
nextcloud_dbpassword_vault: vaultmeplease
nextcloud_passwordsalt_vault: vaultmeplease
nextcloud_secret_vault: vaultmeplease
nextcloud_instanceid_vault: vaultmeplease
nextcloud_admin_user_vault: admin
nextcloud_admin_password_vault: vaultmeplease

Und Ihre Gruppenvariablen in group_vars/nextcloud.yml:

# Nextcloud
nextcloud_domain: "yourdomain.com"
nextcloud_admin_user: "{{ nextcloud_admin_user_vault }}"
nextcloud_admin_password: "{{ nextcloud_admin_password_vault }}"
nextcloud_instanceid: "{{ nextcloud_instanceid_vault }}"
nextcloud_passwordsalt: "{{ nextcloud_passwordsalt_vault }}"
nextcloud_secret: "{{ nextcloud_secret_vault }}"
nextcloud_dbpassword: "{{ nextcloud_dbpassword_vault }}"
nextcloud_apps: [calendar]

# MySQL
mysql_root_password: "{{ mysql_root_password_vault }}"
mysql_bind_address: 127.0.0.1
mysql_packages:
  - mariadb-client
  - mariadb-server
  - python-mysqldb
mysql_databases:
  - name: nextcloud
    encoding: utf8mb4
    collation: utf8mb4_general_ci
mysql_users:
  - name: nextcloud
    host: "localhost"
    password: "{{ nextcloud_dbpassword }}"
    priv: "nextcloud.*:ALL"
    state: present

# Nginx
nginx_remove_default_vhost: true
nginx_service_enabled: true
nginx_service_state: started
nginx_listen_ipv6: false
nginx_vhosts:
  - listen: {{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:443 ssl http2 default_server
    server_name: "{{ nextcloud_domain }}"
    state: "present"
    root: "/var/www/{{ nextcloud_domain }}/current/nextcloud"
    index: index.php
    extra_parameters: |
      add_header Referrer-Policy "no-referrer" always;
      add_header X-Content-Type-Options "nosniff" always;
      add_header X-Download-Options "noopen" always;
      add_header X-Frame-Options "SAMEORIGIN" always;
      add_header X-Permitted-Cross-Domain-Policies "none" always;
      add_header X-Robots-Tag "none" always;
      add_header X-XSS-Protection "1; mode=block" always;

      ssl_certificate /root/.acme.sh/{{ nextcloud_domain }}/fullchain.cer;
      ssl_certificate_key /root/.acme.sh/{{ nextcloud_domain }}/{{ nextcloud_domain }}.key;
      include /etc/nginx/generic.conf;
      include /etc/nginx/gzip.conf;
      include /etc/nginx/security.conf;
      include /etc/nginx/ssl.conf;

      location = /.well-known/carddav {
        return 301 $scheme://$host/remote.php/dav;
      }

      location = /.well-known/caldav {
        return 301 $scheme://$host/remote.php/dav;
      }

      client_max_body_size 512M;
      fastcgi_buffers 64 4K;

      location / {
        rewrite ^ /index.php;
      }

      location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
          deny all;
      }
      location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
          deny all;
      }

      location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
        fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
        set $path_info $fastcgi_path_info;
        try_files $fastcgi_script_name =404;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTPS on;
        fastcgi_param modHeadersAvailable true;
        fastcgi_param front_controller_active true;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
      }

      location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
        try_files $uri/ =404;
        index index.php;
      }

      location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
        try_files $uri /index.php$request_uri;
        add_header Cache-Control "public, max-age=15778463";
        add_header Referrer-Policy "no-referrer" always;
        add_header X-Content-Type-Options "nosniff" always;
        add_header X-Download-Options "noopen" always;
        add_header X-Frame-Options "SAMEORIGIN" always;
        add_header X-Permitted-Cross-Domain-Policies "none" always;
        add_header X-Robots-Tag "none" always;
        add_header X-XSS-Protection "1; mode=block" always;
        access_log off;
      }

      location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
        try_files $uri /index.php$request_uri;
        access_log off;
      }

# PHP
php_default_version_debian: "8.2"
php_packages:
  - php8.2-cli
  - php8.2-fpm
php_install_recommends: false
php_enable_webserver: false
php_enable_php_fpm: true
php_enable_apc: false
php_memory_limit: "512M"
php_upload_max_filesize: "512M"
php_post_max_size: "512M"
php_date_timezone: "Europe/Paris"
php_opcache_zend_extension: "opcache.so"
php_opcache_enable: "1"
php_opcache_enable_cli: "0"
php_opcache_memory_consumption: "128"
php_opcache_interned_strings_buffer: "16"
php_opcache_max_accelerated_files: "10000"
php_opcache_max_wasted_percentage: "5"
php_opcache_validate_timestamps: "0"
php_opcache_revalidate_path: "0"
php_opcache_revalidate_freq: "1"
php_opcache_max_file_size: "0"

Entwicklerdokumentation

Entwicklerdokumentation

Lizenz

GPLv3

Über das Projekt

Ansible role to install nextcloud

Installieren
ansible-galaxy install nierdz.nextcloud
GitHub Repository
Lizenz
gpl-3.0
Downloads
1.4k
Besitzer