2023-03-17 10:34:15 +01:00
|
|
|
---
|
|
|
|
|
2023-04-03 09:19:13 +02:00
|
|
|
- name: Ensure Nextcloud paths exists
|
2023-03-17 10:34:15 +01:00
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item.path }}"
|
2023-04-03 09:19:13 +02:00
|
|
|
state: "{{ item.state }}"
|
2023-03-17 10:34:15 +01:00
|
|
|
mode: 0700
|
|
|
|
owner: "{{ nextcloud_uid }}"
|
|
|
|
group: "{{ nextcloud_gid }}"
|
|
|
|
with_items:
|
2023-04-03 09:19:13 +02:00
|
|
|
- path: "{{ nextcloud_base_path }}"
|
|
|
|
state: directory
|
|
|
|
when: true
|
|
|
|
- path: "{{ nextcloud_config_path }}"
|
|
|
|
state: directory
|
|
|
|
when: true
|
|
|
|
- path: "{{ nextcloud_data_path }}"
|
|
|
|
state: directory
|
|
|
|
when: true
|
|
|
|
- path: "{{ nextcloud_customized_container_src_path }}"
|
|
|
|
state: directory
|
|
|
|
when: "{{ nextcloud_container_image_customizations_enabled }}"
|
|
|
|
- path: "{{ nextcloud_redis_session_ini_path }}"
|
|
|
|
state: "{{ 'touch' if nextcloud_redis_is_configured else 'absent' }}"
|
|
|
|
when: true
|
Preview generator setup (#7)
* Preview generator setup
Enable the variable nextcloud_preview_enabled and you are good to go.
Some important aspects of usage:
- the preview generator has two stages [according to their readme](https://github.com/nextcloud/previewgenerator)
- a generate-all phase, which has to be executed only a single time
- a pre-generate phase, that should be run in a cronjob.
That runs quite fast if the generate-all phase finishd.
We do not want to run the generate-all phase multiple times, so its execution has to be followed somehow.
This is done by creating a file on the host side and both the task that executes generate-all
and both the cronjob checks its existance.
Multiple vaiables are also defined and the corresponding default values are also set.
These values are based on the [upstream readme](https://github.com/nextcloud/previewgenerator) and also on experience.
Feel free to change anything.
Once installed, the playbook needs to be called with the adjust-nextcloud-config tag.
This tag sets up the variables and calls the generate-all script, that will also create the file---signalling
its finished state---on the host.
*** As this may take a long time, be sure to only call it when you have time to leave it running!!! ***
The playbook calls generate-all asynchronously, but it will timeout after about 27h.
On 60GBs, most if images, it took about 10 minutes to finish.
If it takes more time, you may want to start it from the host by calling
```sh
/usr/bin/env docker exec mash-nextcloud-server php /var/www/html/occ preview:generate-all
```
If the nextcloud_preview_enabled value is set back to false, the host side files are cleaned up
and also the cron job is changed, not to call prevew generation again however, the database and generated
previews are kept intact.
* fix playbook format suggestions by Slavi (see conversation in !7)
2023-09-16 09:01:20 +02:00
|
|
|
- path: "{{ nextcloud_preview_host_folder }}"
|
|
|
|
state: "{{ 'directory' if nextcloud_preview_enabled else 'absent' }}"
|
|
|
|
when: true
|
2023-03-17 10:34:15 +01:00
|
|
|
when: item.when | bool
|
|
|
|
|
|
|
|
- name: Ensure Nextcloud support files installed
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "{{ role_path }}/templates/{{ item }}.j2"
|
|
|
|
dest: "{{ nextcloud_config_path }}/{{ item }}"
|
|
|
|
mode: 0640
|
|
|
|
with_items:
|
|
|
|
- env
|
|
|
|
- labels
|
|
|
|
|
Preview generator setup (#7)
* Preview generator setup
Enable the variable nextcloud_preview_enabled and you are good to go.
Some important aspects of usage:
- the preview generator has two stages [according to their readme](https://github.com/nextcloud/previewgenerator)
- a generate-all phase, which has to be executed only a single time
- a pre-generate phase, that should be run in a cronjob.
That runs quite fast if the generate-all phase finishd.
We do not want to run the generate-all phase multiple times, so its execution has to be followed somehow.
This is done by creating a file on the host side and both the task that executes generate-all
and both the cronjob checks its existance.
Multiple vaiables are also defined and the corresponding default values are also set.
These values are based on the [upstream readme](https://github.com/nextcloud/previewgenerator) and also on experience.
Feel free to change anything.
Once installed, the playbook needs to be called with the adjust-nextcloud-config tag.
This tag sets up the variables and calls the generate-all script, that will also create the file---signalling
its finished state---on the host.
*** As this may take a long time, be sure to only call it when you have time to leave it running!!! ***
The playbook calls generate-all asynchronously, but it will timeout after about 27h.
On 60GBs, most if images, it took about 10 minutes to finish.
If it takes more time, you may want to start it from the host by calling
```sh
/usr/bin/env docker exec mash-nextcloud-server php /var/www/html/occ preview:generate-all
```
If the nextcloud_preview_enabled value is set back to false, the host side files are cleaned up
and also the cron job is changed, not to call prevew generation again however, the database and generated
previews are kept intact.
* fix playbook format suggestions by Slavi (see conversation in !7)
2023-09-16 09:01:20 +02:00
|
|
|
- when: "nextcloud_preview_enabled | bool"
|
|
|
|
name: Ensure Nextcloud preview generator files are present
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "{{ role_path }}/templates/preview-generator/{{ item }}.j2"
|
|
|
|
dest: "{{ nextcloud_preview_host_folder }}/{{ item }}"
|
|
|
|
mode: 0740
|
|
|
|
with_items:
|
|
|
|
- preview-generator-cron.sh
|
|
|
|
|
2023-03-17 10:34:15 +01:00
|
|
|
- name: Ensure Nextcloud container image is pulled
|
|
|
|
community.docker.docker_image:
|
|
|
|
name: "{{ nextcloud_container_image }}"
|
|
|
|
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
|
|
|
force_source: "{{ nextcloud_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
|
|
|
|
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else nextcloud_container_image_force_pull }}"
|
|
|
|
register: result
|
|
|
|
retries: "{{ devture_playbook_help_container_retries_count }}"
|
|
|
|
delay: "{{ devture_playbook_help_container_retries_delay }}"
|
|
|
|
until: result is not failed
|
|
|
|
|
|
|
|
- when: "nextcloud_container_image_customizations_enabled | bool"
|
|
|
|
block:
|
|
|
|
- name: Ensure customizations Dockerfile is created
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "{{ role_path }}/templates/customizations/Dockerfile.j2"
|
|
|
|
dest: "{{ nextcloud_customized_container_src_path }}/Dockerfile"
|
2023-04-02 18:11:28 +02:00
|
|
|
owner: "{{ nextcloud_uid }}"
|
|
|
|
group: "{{ nextcloud_gid }}"
|
2023-03-17 10:34:15 +01:00
|
|
|
mode: 0640
|
2023-07-06 19:11:55 +02:00
|
|
|
register: nextcloud_container_image_customizations_dockerfile_result
|
2023-03-17 10:34:15 +01:00
|
|
|
|
|
|
|
- name: Ensure customized container image for Nextcloud is built
|
|
|
|
community.docker.docker_image:
|
|
|
|
name: "{{ nextcloud_container_image_customized }}"
|
|
|
|
source: build
|
2023-07-06 19:11:55 +02:00
|
|
|
force_source: "{{ nextcloud_container_image_customizations_dockerfile_result.changed }}"
|
2023-03-17 10:34:15 +01:00
|
|
|
build:
|
|
|
|
dockerfile: Dockerfile
|
|
|
|
path: "{{ nextcloud_customized_container_src_path }}"
|
|
|
|
pull: true
|
|
|
|
|
|
|
|
- name: Ensure Nextcloud container network is created
|
|
|
|
community.general.docker_network:
|
|
|
|
name: "{{ nextcloud_container_network }}"
|
|
|
|
driver: bridge
|
|
|
|
|
|
|
|
- name: Ensure Nextcloud systemd services installed
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "{{ role_path }}/templates/systemd/{{ item }}.j2"
|
|
|
|
dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ nextcloud_identifier }}-{{ item }}"
|
|
|
|
mode: 0640
|
|
|
|
with_items:
|
|
|
|
- server.service
|
|
|
|
- cron.service
|
|
|
|
- cron.timer
|
2024-05-08 15:34:41 +02:00
|
|
|
|
|
|
|
- when: "nextcloud_auto_app_update_enabled | bool"
|
|
|
|
block:
|
|
|
|
- name: Ensure Nextcloud app update systemd services installed
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: "{{ role_path }}/templates/systemd/{{ item }}.j2"
|
|
|
|
dest: "{{ devture_systemd_docker_base_systemd_path }}/{{ nextcloud_identifier }}-{{ item }}"
|
|
|
|
mode: 0640
|
|
|
|
with_items:
|
|
|
|
- app-update.service
|
|
|
|
- app-update.timer
|
|
|
|
|
|
|
|
- when: "not nextcloud_auto_app_update_enabled | bool"
|
|
|
|
block:
|
|
|
|
- name: Ensure Nextcloud systemd app update services do not exists
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ devture_systemd_docker_base_systemd_path }}/{{ nextcloud_identifier }}-{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- app-update.service
|
|
|
|
- app-update.timer
|
|
|
|
|