--- - name: prepare nextcloud system disk as LVM when: nextcloud_lvm.system is defined vars: lvm_volume: vg: "{{ nextcloud_lvm.system.vg }}" lv: "{{ nextcloud_lvm.system.lv }}" size: "{{ nextcloud_lvm.system.size }}" fs: "{{ nextcloud_lvm.system.fs }}" dest: /srv/nextcloud include_role: name: storage/lvm/volume - name: prepare nextcloud data disk as LVM when: nextcloud_lvm.data is defined vars: lvm_volume: vg: "{{ nextcloud_lvm.data.vg }}" lv: "{{ nextcloud_lvm.data.lv }}" size: "{{ nextcloud_lvm.data.size }}" fs: "{{ nextcloud_lvm.data.fs }}" dest: /srv/ncdata include_role: name: storage/lvm/volume - name: create nextcloud config directory file: path: /srv/nextcloud/config/ state: directory - name: install nextcloud fpm config snippet template: src: nextcloud-fpm.conf.j2 dest: /srv/nextcloud/config/nextcloud-fpm.conf - name: create docker build-context for patched nextcloud image file: path: /srv/nextcloud/docker/ state: directory - name: install Dockerfile for patched nextcloud image template: src: nextcloud-Dockerfile.j2 dest: /srv/nextcloud/docker/Dockerfile register: nextcloud_dockerfile - name: build patched nextcloud image docker_image: state: present name: nextcloud tag: "{{ inventory_hostname }}" source: build build: path: /srv/nextcloud/docker/ pull: no force_source: "{{ nextcloud_dockerfile.changed }}" ### TODO: set mysql variables: ### ### [mysqld] ### transaction_isolation = READ-COMMITTED ### binlog_format = ROW ### - name: create nextcloud database mysql_db: login_user: root login_unix_socket: /var/run/mysqld/mysqld.sock db: "{{ nextcloud_db.db }}" encoding: utf8mb4 collation: utf8mb4_general_ci state: present - name: create nextcloud database user mysql_user: login_user: root login_unix_socket: /var/run/mysqld/mysqld.sock name: "{{ nextcloud_db.user }}" password: "{{ nextcloud_db.password }}" priv: "{{ nextcloud_db.db }}.*:SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,INDEX,ALTER,CREATE TEMPORARY TABLES" state: present ## to purge exisiting installation run the following commands (!!! will delete all data and the DB !!!): # # systemctl disable nextcloud-cron.timer # systemctl stop nextcloud-cron.timer # systemctl disable nextcloud-rescan.timer # systemctl stop nextcloud-rescan.timer # systemctl disable nextcloud.service # systemctl stop nextcloud.service # docker rm nextcloud.service # rm -rf /srv/nextcloud/config/nextcloud # rm -rf /srv/ncdata/nextcloud # rm -rf /srv/nextcloud/www # echo "drop database nextcloud;" | mysql --defaults-extra-file=/etc/mysql/debian.cnf # - name: check if nextcloud is already configured stat: path: /srv/nextcloud/config/nextcloud/config.php register: nextcloud_config_file - name: running nextcloud installer when: not nextcloud_config_file.stat.exists docker_container: name: nextcloud.installer image: "nextcloud:{{ inventory_hostname }}" ## For some reasons a newly created database schema is not up to date with the recommended settings... ## so we will run the migrations right away. If in future this is not needed anymore use '/bin/true' here. command: 'su -p www-data -s /bin/sh -c "php /var/www/html/occ db:convert-filecache-bigint"' network_mode: host detach: no auto_remove: yes volumes: - /srv/nextcloud/www:/var/www/html - /srv/nextcloud/config/nextcloud-fpm.conf:/usr/local/etc/php-fpm.d/zzzzz.conf - /srv/nextcloud/config/nextcloud:/var/www/html/config - /srv/ncdata/nextcloud:/var/www/html/data - /srv/smbdata/share:/srv/external/share env: NEXTCLOUD_UPDATE: '1' NEXTCLOUD_TRUSTED_DOMAINS: "{{ nextcloud_hostnames | join(' ') }}" MYSQL_DATABASE: "{{ nextcloud_db.db }}" MYSQL_HOST: "127.0.0.1:3306" MYSQL_USER: "{{ nextcloud_db.user }}" MYSQL_PASSWORD: "{{ nextcloud_db.password }}" NEXTCLOUD_ADMIN_USER: "{{ nextcloud_admin.username }}" NEXTCLOUD_ADMIN_PASSWORD: "will-be-changed-later" - name: configure nextcloud upload file size limit loop: - upload_max_filesize - post_max_size lineinfile: path: /srv/nextcloud/www/.user.ini regexp: '^{{ item }}=' line: '{{ item }}={{ nextcloud_max_upload_size }}' - name: configure nextcloud memory limit lineinfile: path: /srv/nextcloud/www/.user.ini regexp: '^memory_limit=' line: 'memory_limit={{ nextcloud_memory_limit }}' - name: install nextcloud service unit template: src: nextcloud.service.j2 dest: /etc/systemd/system/nextcloud.service register: nextcloud_service - name: make sure nextcloud is started and enabled systemd: name: nextcloud.service state: "{% if nextcloud_service.changed %}restarted{% else %}started{% endif %}" enabled: yes daemon_reload: yes - name: basic nextcloud config import_tasks: nextcloud-config.yml - name: install nextcloud systemd units loop: - cron.service - cron.timer - rescan.service - rescan.timer template: src: "nextcloud-{{ item }}.j2" dest: "/etc/systemd/system/nextcloud-{{ item }}" - name: make sure nextcloud systemd timer are started and enabled loop: - cron - rescan systemd: name: "nextcloud-{{ item }}.timer" state: started enabled: yes daemon_reload: yes