---
# file: roles/borgbackup/tasks/config_nextcloud.yml

- name: Set facts
  set_fact:
    application: 'nextcloud'
    application_id: '{{ nextcloud.id }}'
    application_remote_repo: '{{ nextcloud.borg_repo|default(false) }}'
- name: Set facts without jails
  set_fact:
    application_dir: '{{ nextcloud_data_dir|default("/var/www/nextcloud/_data") }}/{{ nextcloud.id }}'
  when: nextcloud.jail is not defined
- name: Set facts with jails
  set_fact:
    application_dir: '{{ jailroot }}/{{ nextcloud.id }}/var/www/datanextcloud'
  when: nextcloud.jail is defined

- name: Configure NextCloud Backup
  template:
    src: application.yaml
    dest: /etc/borgmatic.d/{{ application }}_{{ application_id }}.yaml
    mode: 0600
  notify:
    - Init Borgs
