summaryrefslogtreecommitdiff
path: root/roles/nextcloud/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/nextcloud/tasks')
-rw-r--r--roles/nextcloud/tasks/download.yml36
-rw-r--r--roles/nextcloud/tasks/installation.yml49
-rw-r--r--roles/nextcloud/tasks/main.yml26
3 files changed, 111 insertions, 0 deletions
diff --git a/roles/nextcloud/tasks/download.yml b/roles/nextcloud/tasks/download.yml
new file mode 100644
index 0000000..0aaf858
--- /dev/null
+++ b/roles/nextcloud/tasks/download.yml
@@ -0,0 +1,36 @@
+- name: install php packages
+ apt:
+ name: '{{ nextcloud_php_present }}'
+ install_recommends: 'no'
+
+- name: nc_download | Create and set directory ownership & permissions for the webroot folder
+ ansible.builtin.file:
+ path: "{{ nextcloud_webroot }}"
+ mode: "u=rwX,g=rX,o-rwx"
+ recurse: true
+ state: directory
+ owner: "{{ nextcloud_websrv_user }}"
+ group: "{{ nextcloud_websrv_group }}"
+
+- name: nc_download | Download and extract Nextcloud
+ block:
+ - name: nc_download | Download & extract Nextcloud to /tmp."
+ ansible.builtin.unarchive:
+ remote_src: true
+ src: "{{ nextcloud_full_src | default(nextcloud_calculated_url) }}"
+ dest: "/tmp/"
+ vars:
+ nextcloud_calculated_url: "{{ nextcloud_repository }}/{{ nextcloud_version_channel }}/{{ nextcloud_calculated_file }}"
+ nextcloud_calculated_file: "{{ nextcloud_dl_file_name + '.' + nextcloud_archive_format }}"
+
+ - name: "nc_download | Move extracted files to {{ nextcloud_webroot }}"
+ ansible.builtin.command: "cp -r /tmp/nextcloud/. {{ nextcloud_webroot }}/"
+ when: nextcloud_webroot is not none
+ register: output
+ changed_when: "output.rc == 0"
+
+ - name: nc_download | Remove nextcloud archive files
+ ansible.builtin.file:
+ path: /tmp/nextcloud
+ state: absent
+
diff --git a/roles/nextcloud/tasks/installation.yml b/roles/nextcloud/tasks/installation.yml
new file mode 100644
index 0000000..5020b88
--- /dev/null
+++ b/roles/nextcloud/tasks/installation.yml
@@ -0,0 +1,49 @@
+- name: install nfs packages
+ apt:
+ name: '{{ nextcloud_nfs_present }}'
+ install_recommends: 'no'
+ state: present
+
+- name: check mountpoint exist
+ ansible.builtin.file:
+ path: "{{ nextcloud_data_dir }}"
+ state: directory
+ mode: 0640
+ owner: www-data
+ group: www-data
+
+- name: mount network share
+ ansible.posix.mount:
+ src: "{{ nextcloud_data_nfs_share }}"
+ path: "{{ nextcloud_data_dir }}"
+ fstype: nfs
+ opts: "rw,sync"
+ state: mounted
+
+- name: "nc_installation | Generate password {{ nextcloud_admin_name }}"
+ ansible.builtin.set_fact:
+ nextcloud_admin_pwd: "{{ lookup('password', '/root/ncpasswd.txt') }}"
+ become: true
+ when: nextcloud_admin_pwd is not defined
+
+- name: nc_installation | Set temporary permissions for command line installation
+ ansible.builtin.file:
+ path: "{{ nextcloud_webroot }}"
+ state: directory
+ recurse: true
+ owner: "{{ nextcloud_websrv_user }}"
+ group: "{{ nextcloud_websrv_group }}"
+
+- name: nc_installation | Verify config.php - check filesize
+ ansible.builtin.stat:
+ path: "{{ nextcloud_webroot }}/config/config.php"
+ register: nc_installation_confsize
+ failed_when: nc_installation_confsize.stat.size is undefined or nc_installation_confsize.stat.size <= 100
+
+- name: nc_installation | Verify config.php - php syntax check
+ ansible.builtin.command: "php -l {{ nextcloud_webroot }}/config/config.php"
+ register: nc_installation_confphp
+ changed_when: false
+ failed_when:
+ - nc_installation_confphp.rc is defined
+ - nc_installation_confphp.rc != 0
diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml
new file mode 100644
index 0000000..485f8f1
--- /dev/null
+++ b/roles/nextcloud/tasks/main.yml
@@ -0,0 +1,26 @@
+- name: Check Nextcloud installed
+ ansible.builtin.stat:
+ path: "{{ nextcloud_webroot }}/index.php"
+ register: nc_nextcloud_installed
+
+- name: Downloading Nextcloud
+ ansible.builtin.include_tasks: download.yml
+ when: not nc_nextcloud_installed.stat.exists
+
+- name: Check Nextcloud configuration exists.
+ ansible.builtin.stat:
+ path: "{{ nextcloud_webroot }}/config/config.php"
+ register: nc_nextcloud_conf
+
+- name: Check Nextcloud is configured
+ ansible.builtin.command: grep -q "{{ nextcloud_trusted_domain | first }}" {{ nextcloud_webroot }}/config/config.php
+ failed_when: false
+ changed_when: false
+ register: nc_nextcloud_configured
+ when: nc_nextcloud_conf.stat.exists
+
+- name: Nextcloud installation
+ ansible.builtin.include_tasks: installation.yml
+ when: |
+ (not nc_nextcloud_conf.stat.exists) or
+ (nc_nextcloud_configured.rc is defined and nc_nextcloud_configured.rc != 0)