---

  - name: "Automatic app update every mondays"
    cron:
      name: "{{ app_instance_root }}/occ app:update --all >/dev/null 2>&1"
      user: "www-data"
      weekday: "1"
      hour: "4"
      minute: "0"
      job: "php{{ php_version }} -f {{ app_instance_root }}/occ app:update --all >/dev/null 2>&1"

  - name: "template for maintenance script"
    template:
      src: "nextcloud_maintenance.j2"
      dest: "{{ app_instance_root }}/nextcloud_maintenance.sh"
      mode: 0700

  - name: "run maintenance script"
    command: "{{ app_instance_root }}/nextcloud_maintenance.sh"

  - name: "remove maintenance script"
    file:
      path: "{{ app_instance_root }}/nextcloud_maintenance.sh"
      state: absent

