From 985cc477b56b642bfc426c1d23a6e0e878fb02d9 Mon Sep 17 00:00:00 2001 From: "Andreas B. Mundt" Date: Sun, 19 Jan 2020 18:47:12 +0100 Subject: [PATCH] Minor fixes and cleanup nextcloud role. --- host_vars/blackbox.yml | 1 + host_vars/bluebox.yml | 1 + roles/nextcloud/defaults/main.yml | 1 + roles/nextcloud/handlers/main.yml | 2 +- roles/nextcloud/tasks/main.yml | 40 ++++++++++++++++++------------- 5 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 host_vars/blackbox.yml create mode 100644 host_vars/bluebox.yml diff --git a/host_vars/blackbox.yml b/host_vars/blackbox.yml new file mode 100644 index 0000000..3fff54c --- /dev/null +++ b/host_vars/blackbox.yml @@ -0,0 +1 @@ +allow_download: True diff --git a/host_vars/bluebox.yml b/host_vars/bluebox.yml new file mode 100644 index 0000000..3fff54c --- /dev/null +++ b/host_vars/bluebox.yml @@ -0,0 +1 @@ +allow_download: True diff --git a/roles/nextcloud/defaults/main.yml b/roles/nextcloud/defaults/main.yml index 4b8122f..f55220f 100644 --- a/roles/nextcloud/defaults/main.yml +++ b/roles/nextcloud/defaults/main.yml @@ -4,3 +4,4 @@ nc_admin_pwd_file: "/root/nc-admin.pwd" www_root: "/var/www" nc_dir: "{{ www_root }}/nextcloud" data_dir: "/var/nc-data" +allow_download: False diff --git a/roles/nextcloud/handlers/main.yml b/roles/nextcloud/handlers/main.yml index 17822fa..f514172 100644 --- a/roles/nextcloud/handlers/main.yml +++ b/roles/nextcloud/handlers/main.yml @@ -15,4 +15,4 @@ name: nextcloudcron.timer state: started enabled: True - listen: "enable nextcloudcron.service" + listen: "enable nextcloudcron.timer" diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index cbe40c4..1ed27f1 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -1,4 +1,24 @@ -## Install and configure nextcloud +## Install and configure nextcloud. + +- name: check if we are installing + stat: path="{{ nc_dir }}" + register: nextcloud + +- name: check for nextcloud archive + local_action: stat path=nextcloud.tar.bz2 + become: No + register: nc_archive + when: not nextcloud.stat.exists + +- name: stop if nextcloud archive is unavailable + fail: + msg: > + The nextcloud archive nextcloud.tar.bz2 is not available. + Download the latest stable release from 'nextcloud.com', + check the signature, rename it and copy it next to 'cloudbox.yml'. + when: not nextcloud.stat.exists and not nc_archive.stat.exists + +## We can start with the installation now: - name: install apache, php- and db-packages apt: @@ -113,12 +133,7 @@ owner: www-data group: www-data - ## install nextcloud: -- name: check if we are installing - stat: path="{{ nc_dir }}" - register: nextcloud - - name: create database with name 'nextcloud' mysql_db: login_unix_socket: /var/run/mysqld/mysqld.sock @@ -186,15 +201,7 @@ with_items: - nextcloudcron.service - nextcloudcron.timer - register: nextcloudcron - notify: "enable nextcloudcron.service" - -- name: switch to systemd timer - command: sudo -u www-data php ./occ background:cron - args: - chdir: "{{ nc_dir }}" - warn: False - when: nextcloudcron.changed + notify: "enable nextcloudcron.timer" - name: check/run upgrade command: sudo -u www-data php updater.phar --no-interaction @@ -203,6 +210,7 @@ warn: False register: cmd_result changed_when: cmd_result.stdout is not search('Nothing to do.') + when: allow_download ### app installations: - name: install extra apps @@ -216,7 +224,7 @@ register: cmd_result changed_when: cmd_result.stdout is not search('already installed') failed_when: cmd_result.stdout is not search('already installed') and cmd_result.rc != 0 - + when: allow_download ## ToDo kerberox integration: # sudo -u www-data php ./occ app:enable user_ldap