Skip to content
Snippets Groups Projects
config_nextcloud.yml 1.63 KiB
Newer Older
---
# file: roles/borgbackup/tasks/config_nextcloud.yml

- name: Set facts
  set_fact:
    application: 'nextcloud'
    application_id: '{{ nextcloud.id }}'
    application_remote_host: '{{ nextcloud.borg_host|default(false) }}'
    application_remote_repo: '{{ nextcloud.borg_repo|default(false) }}'
    application_disable_local: '{{ nextcloud.borg_disable_local|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

jurgenhaas's avatar
jurgenhaas committed
- name: Ensure local backup directory
  file:
    dest: /var/backups/borg/{{ application }}_{{ application_id }}
    owner: root
    group: root
    state: directory
    mode: 0700
  when: not application_disable_local

- name: Configure NextCloud Backup
  template:
    src: application.yaml
    dest: /etc/borgmatic.d/{{ application }}_{{ application_id }}.yaml
    mode: 0600
  notify:
    - Init Borgs
- name: Configure Nextcloud Check
  template:
    src: check_application.yaml
    dest: /etc/borgmatic.d/check/{{ application }}_{{ application_id }}.yaml
    mode: 0600
  notify:
    - Init Borgs
  when: not application_disable_local|default(false)

- name: Add repo server host key to known hosts
  known_hosts:
    name: '{{ application_remote_host }}'
    key: "{{ application_remote_host }} {{ borgbackup_public_key }}"
    hash_host: no
  ignore_errors: yes
  when: borgbackup_public_key is defined and application_remote_host