Newer
Older
- name: Register Nextcloud in inventory
import_role:
- name: Create LetsEncrypt certificate
import_role:
- name: Create Database for Nextcloud
import_role:
- import_tasks: volume.yml
when: hcloud_token is defined
- name: create temporary download directory
tempfile:
state: directory
suffix: "_app_new"
register: _tmp_new_app
changed_when: False
- name: "check local release {{ local_release }} for nextcloud__instance"
local_action: stat path=$PWD/{{ local_release }}
register: local_release_file
- name: "retrieving nextcloud version {{ app_version }} in {{ _tmp_new_app.path }} {{ app_instance_root }}"
src: "https://download.nextcloud.com/server/releases/nextcloud-{{ app_version }}.tar.bz2"
dest: "{{ _tmp_new_app.path }}"
group: "www-data"
owner: "www-data"
creates: "{{ app_instance_root }}"
when: not(local_release_file.stat.exists)
- name: "retrieving nextcloud from ./{{ local_release }} in {{ _tmp_new_app.path }}"
unarchive:
src: "{{ local_release }}"
dest: "{{ _tmp_new_app.path }}"
group: "www-data"
owner: "www-data"
creates: "{{ app_instance_root }}"
when: local_release_file.stat.exists
- name: "Move {{ _tmp_new_app.path }}/nextcloud to {{ app_instance_root }}"
command: "/bin/mv {{ _tmp_new_app.path }}/nextcloud {{ app_instance_root }}"
args:
creates: "{{ app_instance_root }}"
- name: "dir {{ app_data }}"
file:
path: "{{ app_data }}"
state: directory
mode: 0700
group: "www-data"
owner: "www-data"
- name: "remove {{ _tmp_new_app.path }}"
file:
path: "{{ _tmp_new_app.path }}"
state: absent
changed_when: False
- name: "cron mode for background jobs"
cron:
name: "{{ app_instance_root }}/cron.php >/dev/null 2>&1"
user: "www-data"
minute: "*/15"
job: "php{{ php_version }} -f {{ app_instance_root }}/cron.php >/dev/null 2>&1"
- name: "test absence of config.php (determines first install)"
stat:
path: "{{ app_instance_root }}/config/config.php"
register: config
- name: "template for install script"
template:
src: "nextcloud_app_install.j2"
dest: "{{ app_instance_root }}/ansible_base_install.sh"
mode: 0700
when: not (config.stat.exists)
- name: "run install script using occ (no idempotency) "
command: "{{ app_instance_root }}/ansible_base_install.sh"
when: not (config.stat.exists)
- name: "remove install script"
file:
path: "{{ app_instance_root }}/ansible_base_install.sh"
state: absent
when: not (config.stat.exists)
- name: "App update every mondays"
cron:
name: "{{ app_instance_root }}/occ app:update --all >/dev/null 2>&1"
user: "www-data"
weekday: "1"
job: "php -f {{ app_instance_root }}/occ app:update --all >/dev/null 2>&1"
- name: Import Backup Role
import_role:
name: _app_logrotate
- name: "template {{ rev_proxy }}_nextcloud.j2 {{ app_instance_id }}"
template:
src: "{{ rev_proxy }}_nextcloud.j2"
dest: "/etc/{{ rev_proxy }}/sites-available/{{ app_instance_id }}.conf"
- name: "enable site for {{ app_domain }}"
file:
state: link
path: "/etc/{{ rev_proxy }}/sites-enabled/{{ app_instance_id }}.conf"
src: "/etc/{{ rev_proxy }}/sites-available/{{ app_instance_id }}.conf"