80 lines
2.3 KiB
YAML
80 lines
2.3 KiB
YAML
---
|
|
- name: "set local variables from overrides and defaults"
|
|
set_fact:
|
|
nextcloud: "{{ (nextcloud_defaults | combine(nextcloud_override, recursive=True)) if nextcloud_override else nextcloud_defaults }}"
|
|
|
|
- name: "set mail variables from overrides and defaults"
|
|
set_fact:
|
|
mail: "{{ (nextcloud_defaults | combine(nextcloud_override, recursive=True)) if nextcloud_override else nextcloud_defaults }}"
|
|
|
|
- set_fact:
|
|
nextcloud_container: "{{ role_name }}-nextcloud-1"
|
|
|
|
- name: ensure that path exists
|
|
file:
|
|
path: "{{ path }}/config/"
|
|
state: directory
|
|
|
|
- name: copy hooks
|
|
copy:
|
|
src: "files/hooks"
|
|
dest: "{{ path }}/config/"
|
|
|
|
- name: template compose
|
|
template:
|
|
src: compose.yml.j2
|
|
dest: "{{ path }}/compose.yml"
|
|
|
|
- name: template nc config
|
|
template:
|
|
src: importconfig.json.j2
|
|
dest: "{{ path }}/config/nextcloud-importconfig.json"
|
|
register: _importconfig
|
|
|
|
- import_role:
|
|
name: storage_mount
|
|
vars:
|
|
storage_mount_override:
|
|
host: "{{ nextcloud.networkmount.host }}"
|
|
host_path: "{{ nextcloud.networkmount.host_path }}"
|
|
args: "{{ nextcloud.networkmount.args }}"
|
|
dest_path: "{{ nextcloud.data_path }}"
|
|
when: nextcloud.networkmount.host | length > 1
|
|
|
|
- name: ensure containers are running
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ path }}"
|
|
project_name: "{{ role_name }}"
|
|
state: "present"
|
|
pull: "always"
|
|
wait: true
|
|
services: >-
|
|
{{ ['db', 'redis', 'nextcloud'] +
|
|
(['collabora'] if nextcloud.collabora.url | default('') else []) +
|
|
(['drawio'] if nextcloud.drawio.url | default('') else []) }}
|
|
register: _compose_result
|
|
|
|
- name: is nextcloud already setup?
|
|
community.docker.docker_container_exec:
|
|
container: "{{ nextcloud_container }}"
|
|
chdir: "/var/www/html/"
|
|
user: "www-data"
|
|
command: php occ status
|
|
register: nextcloud_status_check
|
|
retries: 3
|
|
changed_when: "false"
|
|
|
|
- name: import config
|
|
community.docker.docker_container_exec:
|
|
container: "{{ nextcloud_container }}"
|
|
chdir: "/var/www/html/"
|
|
user: "www-data"
|
|
command: "php occ config:import /tmp/importconfig.json"
|
|
when: "_importconfig.changed or 'installed: false' in nextcloud_status_check.stdout"
|
|
|
|
- name: Ensure nextcloud cron exists
|
|
cron:
|
|
name: Nextcloud periodic tasks
|
|
minute: "*/5"
|
|
job: "docker exec -u 33 {{ nextcloud_container }} php cron.php"
|