summaryrefslogtreecommitdiff
path: root/roles/apps/nextcloud/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/apps/nextcloud/tasks')
-rw-r--r--roles/apps/nextcloud/tasks/custom-image.yml31
-rw-r--r--roles/apps/nextcloud/tasks/main.yml239
2 files changed, 3 insertions, 267 deletions
diff --git a/roles/apps/nextcloud/tasks/custom-image.yml b/roles/apps/nextcloud/tasks/custom-image.yml
deleted file mode 100644
index 3d9e31d1..00000000
--- a/roles/apps/nextcloud/tasks/custom-image.yml
+++ /dev/null
@@ -1,31 +0,0 @@
----
-- name: create build directory for custom image
- file:
- path: "{{ nextcloud_base_path }}/{{ item.key }}/build"
- state: directory
-
-- name: generate Dockerfile for custom image
- copy:
- content: |
- FROM {{ item.value.custom_image.from | default('nextcloud:' + item.value.version) }}
-
- RUN set -x \
- && addgroup --gid {{ nextcloud_app_gid }} nc-app \
- && adduser --uid {{ nextcloud_app_uid }} --gid {{ nextcloud_app_gid }} --system --no-create-home --home /var/www/html --disabled-login --disabled-password nc-app
- {% if 'custom_image' in item.value %}
-
- {{ item.value.custom_image.dockerfile }}
- {% endif %}
- dest: "{{ nextcloud_base_path }}/{{ item.key }}/build/Dockerfile"
- register: nextcloud_custom_image_docker
-
-- name: build custom image
- docker_image:
- name: "nextcloud/{{ item.key }}:{{ item.value.version }}"
- state: present
- force_source: "{{ nextcloud_custom_image_docker is changed }}"
- source: build
- build:
- path: "{{ nextcloud_base_path }}/{{ item.key }}/build"
- network: host
- pull: yes
diff --git a/roles/apps/nextcloud/tasks/main.yml b/roles/apps/nextcloud/tasks/main.yml
index d1a11b19..6e81f351 100644
--- a/roles/apps/nextcloud/tasks/main.yml
+++ b/roles/apps/nextcloud/tasks/main.yml
@@ -1,240 +1,7 @@
---
-- name: create zfs datasets
- when: nextcloud_zfs is defined
- block:
- - name: create zfs base dataset
- zfs:
- name: "{{ nextcloud_zfs.pool }}/{{ nextcloud_zfs.name }}"
- state: present
- extra_zfs_properties: "{{ nextcloud_zfs.properties | dehumanize_zfs_properties | default(omit) }}"
-
- - name: create zfs volumes for instances
- loop: "{{ nextcloud_instances | dict2items }}"
- loop_control:
- label: "{{ item.key }} ({{ (item.value.zfs_properties | default({})).items() | map('join', '=') | join(', ') }})"
- zfs:
- name: "{{ nextcloud_zfs.pool }}/{{ nextcloud_zfs.name }}/{{ item.key }}"
- state: present
- extra_zfs_properties: "{{ item.value.zfs_properties | dehumanize_zfs_properties | default(omit) }}"
-
- - name: configure nextcloud base bath
- set_fact:
- nextcloud_base_path: "{{ (zfs_pools[nextcloud_zfs.pool].mountpoint, nextcloud_zfs.name) | path_join }}"
-
-
-- name: create instance subdirectories
- when: nextcloud_zfs is not defined
+- name: instance specific tasks
loop: "{{ nextcloud_instances | list }}"
- file:
- path: "{{ nextcloud_base_path }}/{{ item }}"
- state: directory
-
-
-
-- name: add group for nextcloud app
- group:
- name: nc-app
- gid: "{{ nextcloud_app_gid }}"
-
-- name: add user for nextcloud app
- user:
- name: nc-app
- uid: "{{ nextcloud_app_uid }}"
- group: nc-app
- password: "!"
-
-- name: create nextcloud app subdirectory
- loop: "{{ nextcloud_instances | list }}"
- file:
- path: "{{ nextcloud_base_path }}/{{ item }}/nextcloud"
- owner: "{{ nextcloud_app_uid }}"
- group: "{{ nextcloud_app_gid }}"
- state: directory
-
-
-- name: add group for nextcloud db
- group:
- name: nc-db
- gid: "{{ nextcloud_db_gid }}"
-
-- name: add user for nextcloud db
- user:
- name: nc-db
- uid: "{{ nextcloud_db_uid }}"
- group: nc-db
- password: "!"
-
-- name: create nextcloud database subdirectory
- loop: "{{ nextcloud_instances | dict2items }}"
- loop_control:
- label: "{{ item.key }} ({{ item.value.database.type }})"
- file:
- path: "{{ nextcloud_base_path }}/{{ item.key }}/{{ item.value.database.type }}"
- owner: "{{ nextcloud_db_uid }}"
- group: "{{ nextcloud_db_gid }}"
- state: directory
-
-
-- name: add group for nextcloud redis
- group:
- name: nc-redis
- gid: "{{ nextcloud_redis_gid }}"
-
-- name: add user for nextcloud redis
- user:
- name: nc-redis
- uid: "{{ nextcloud_redis_uid }}"
- group: nc-redis
- password: "!"
-
-- name: create nextcloud database subdirectory
- loop: "{{ nextcloud_instances | list }}"
- file:
- path: "{{ nextcloud_base_path }}/{{ item }}/redis"
- owner: "{{ nextcloud_redis_uid }}"
- group: "{{ nextcloud_redis_gid }}"
- state: directory
-
-
-- name: create auxiliary config directory
- loop: "{{ nextcloud_instances | list }}"
- file:
- path: "{{ nextcloud_base_path }}/{{ item }}/config"
- state: directory
-
-- name: create apache vhost config
- loop: "{{ nextcloud_instances | list }}"
- template:
- src: apache-site.conf.j2
- dest: "{{ nextcloud_base_path }}/{{ item }}/config/apache-site.conf"
-
-- name: configure apache to run on port 8080 only
- loop: "{{ nextcloud_instances | list }}"
- copy:
- content: |
- Listen 8080
- dest: "{{ nextcloud_base_path }}/{{ item }}/config/ports.conf"
-
-
-- name: build custom image
- loop: "{{ nextcloud_instances | dict2items }}"
- loop_control:
- label: "{{ item.key }}"
- # when: "'custom_image' in item.value"
- include_tasks: custom-image.yml
-
-- name: install pod manifest
- loop: "{{ nextcloud_instances | dict2items }}"
loop_control:
- label: "{{ item.key }}"
- vars:
- kubernetes_standalone_pod:
- name: "nextcloud-{{ item.key }}"
- spec: "{{ lookup('template', 'pod-spec-with-{{ item.value.database.type }}.yml.j2') }}"
- mode: "0600"
- config_hash_items:
- - path: "{{ nextcloud_base_path }}/{{ item.key }}/config/apache-site.conf"
- properties:
- - checksum
- - path: "{{ nextcloud_base_path }}/{{ item.key }}/config/ports.conf"
- properties:
- - checksum
- - path: "{{ nextcloud_base_path }}/{{ item.key }}/build/Dockerfile"
- properties:
- - checksum
+ loop_var: nextcloud_instance
include_role:
- name: kubernetes/standalone/pod
-
-
-- name: install cron trigger script
- loop: "{{ nextcloud_instances | list }}"
- template:
- src: run-cron.sh.j2
- dest: "{{ nextcloud_base_path }}/{{ item }}/config/run-cron.sh"
- mode: 0755
-
-- name: install template systemd unit for cron trigger
- template:
- src: cron@.service.j2
- dest: /etc/systemd/system/nextcloud-cron@.service
-
-- name: install systemd timer unit
- loop: "{{ nextcloud_instances | list }}"
- template:
- src: cron-.timer.j2
- dest: "/etc/systemd/system/nextcloud-cron-{{ item }}.timer"
-
-- name: start/enable cron trigger systemd timer
- loop: "{{ nextcloud_instances | list }}"
- systemd:
- daemon_reload: yes
- name: "nextcloud-cron-{{ item }}.timer"
- state: started
- enabled: yes
-
-
-- name: configure nginx vhost
- loop: "{{ nextcloud_instances | dict2items }}"
- loop_control:
- label: "{{ item.key }}"
- vars:
- nginx_vhost:
- name: "nextcloud-{{ item.key }}"
- template: generic
- tls:
- certificate_provider: "{{ acme_client }}"
- hostnames: "{{ item.value.hostnames }}"
- locations:
- '/':
- proxy_pass: "http://127.0.0.1:{{ item.value.port }}"
- proxy_redirect:
- - redirect: "http://$host/"
- replacement: "https://$host/"
- - redirect: "http://$host:8080/"
- replacement: "https://$host/"
- extra_directives: |-
- client_max_body_size 0;
- types {
- text/javascript js mjs;
- }
- include_role:
- name: nginx/vhost
-
-
-- name: install management scripts
- loop:
- - nextcloud-upgrade
- - nextcloud-occ
- template:
- src: "{{ item }}.j2"
- dest: "/usr/local/bin/{{ item }}"
- mode: 0755
-
-## TODO:
-# do this automatically!
-- name: print info for new instance
- loop: "{{ nextcloud_instances | dict2items }}"
- loop_control:
- label: "{{ item.key }}"
- when: "'new' in item.value and item.value.new"
- pause:
- seconds: 5
- prompt: |
- ************* {{ item.key }} is a new instance
- **
- ** Go to https://{{ item.value.hostnames[0] }} and finalize the
- ** installation. After that run the following commands:
- **
- ** $ nextcloud-occ {{ item.key }} config:system:set default_phone_region --value='at'
- ** $ nextcloud-occ {{ item.key }} config:system:set memcache.locking --value '\OC\Memcache\Redis'
- ** $ nextcloud-occ {{ item.key }} config:system:set redis host --value '127.0.0.1'
- ** $ nextcloud-occ {{ item.key }} config:system:set redis port --type integer --value 6379
- ** $ nextcloud-occ {{ item.key }} config:system:set redis timeout --type float --value 0.0
- ** $ nextcloud-occ {{ item.key }} config:system:set redis password
- **
- ** in case you want to use an exteranl collabora/code server:
- **
- ** $ nextcloud-occ {{ item.key }} app:disable richdocumentscode
- ** $ nextcloud-occ {{ item.key }} app:remove richdocumentscode
- **
- ****************************************
+ name: apps/nextcloud/instance