Compare commits

...

5 Commits

36 changed files with 346 additions and 54 deletions

View File

@ -51,7 +51,7 @@ certbot_webroot_path: "/var/lib/letsencrypt/" # Path used by
certbot_cert_path: "/etc/letsencrypt/live" # Path containing active certificate symlinks for domains
## Docker Role Specific Parameters
docker_restart_policy: "unless-stopped"
docker_restart_policy: "unless-stopped"
# helper
_applications_nextcloud_oidc_flavor: "{{ applications.nextcloud.oidc.flavor | default('oidc_login' if applications.nextcloud.features.ldap | default(true) else 'sociallogin') }}"
_applications_nextcloud_oidc_flavor: "{{ applications.nextcloud.oidc.flavor | default('oidc_login' if applications.nextcloud.features.ldap | default(true) else 'sociallogin') }}"

View File

@ -57,6 +57,7 @@ ports:
presentation: 8039
espocrm: 8040
syncope: 8041
collabora: 8042
bigbluebutton: 48087 # This port is predefined by bbb. @todo Try to change this to a 8XXX port
# Ports which are exposed to the World Wide Web
public:

View File

@ -84,6 +84,8 @@ defaults_networks:
subnet: 192.168.103.64/28
syncope:
subnet: 192.168.103.80/28
collabora:
subnet: 192.168.103.96/28
# /24 Networks / 254 Usable Clients
bigbluebutton:

View File

@ -28,8 +28,8 @@ defaults_oidc:
attributes:
# Attribut to identify the user
username: "preferred_username"
given_name: "given_name"
family_name: "family_name"
given_name: "givenName"
family_name: "surname"
email: "email"
#############################################

View File

@ -0,0 +1,30 @@
# Docker Collabora (DRAFT)
## Description
This Ansible role deploys Collabora Online (CODE) in Docker to enable real-time, in-browser document editing for Nextcloud. It automates the setup of the Collabora CODE container, Nginx reverse proxy configuration, network isolation via Docker networks, and environment variable management.
## Overview
* **Dockerized Collabora CODE:** Uses the official `collabora/code` image.
* **Nginx Reverse Proxy:** Configures a public-facing proxy with TLS termination and WebSocket support for `/cool/` paths.
* **Docker Network Management:** Creates an isolated `/28` subnet for Collabora and connects containers securely.
* **Environment Configuration:** Generates a `.env` file with domain, credentials, and extra parameters for Collabora's WOPI server.
## Features
* Automatic creation of a dedicated Docker network for Collabora.
* Proxy configuration template for Nginx with long timeouts and WebSocket upgrades.
* Customizable domain names and ports via Ansible variables.
* Support for SSL termination at the proxy level.
* Integration hooks to restart Nginx and recreate Docker Compose stacks on changes.
## Documentation
See the roles `README.md`, task files, and Jinja2 templates in the `roles/docker-collabora` directory for usage examples and variable definitions.
## Further Resources
* [Collabora & Talk Super integration demo](https://www.youtube.com/watch?v=7cRmvTyt1ik)
* [Collabora configuration examples archive](https://cloud.thesysadminhub.com/s/FNKyP43y35HGDTJ?dir=/&openfile=true)
* [Official Collabora CODE website](https://www.collaboraoffice.com/code/)

View File

@ -0,0 +1,28 @@
---
galaxy_info:
author: "Kevin Veen-Birkenbach"
description: "Deploy Collabora Online CODE in Docker with automated proxy, networking, and environment configuration."
license: "CyMaIS NonCommercial License (CNCL)"
license_url: "https://s.veen.world/cncl"
company: |
Kevin Veen-Birkenbach
Consulting & Coaching Solutions
https://www.veen.world
min_ansible_version: "2.9"
platforms:
- name: Linux
versions:
- all
galaxy_tags:
- collabora
- docker
- nginx
- office
- wopi
- code
repository: "https://s.veen.world/cymais"
issue_tracker_url: "https://s.veen.world/cymaisissues"
documentation: "https://s.veen.world/cymais/docker-collabora"
logo:
class: "fa-solid fa-file-code"
run_after: []

View File

@ -0,0 +1,20 @@
- name: create nextcloud nginx proxy configuration file
template:
src: "nginx.conf.j2"
dest: "{{nginx.directories.http.servers}}{{domains | get_domain(application_id)}}.conf"
notify: restart nginx
- name: "Include docker-compose role"
include_role:
name: docker-compose
- name: Create Docker network for Collabora
docker_network:
name: central_mariadb
state: present
ipam_config:
- subnet: "{{ networks.local.collabora.subnet }}"
when: run_once_docker_mariadb is not defined
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"

View File

@ -0,0 +1,15 @@
services:
{% include 'templates/docker/services/redis.yml.j2' %}
collabora:
image: collabora/code
container_name: collabora
ports:
- "127.0.0.1:{{ports.localhost.http[application_id]}}:80"
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
{% include 'templates/docker/container/depends-on-database-redis.yml.j2' %}
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'templates/docker/compose/networks.yml.j2' %}

View File

@ -0,0 +1,4 @@
domain=nxsrv
username=admin
password=${COLLABRA_PASSWORD}
extra_params=--o:ssl.enable=false --o:ssl.termination=true

View File

@ -0,0 +1,15 @@
server {
server_name {{domain}};
{% include 'roles/letsencrypt/templates/ssl_header.j2' %}
{% include 'roles/nginx-modifier-all/templates/global.includes.conf.j2'%}
{% include 'roles/nginx-docker-reverse-proxy/templates/headers/content_security_policy.conf.j2' %}
{% include 'roles/nginx-docker-reverse-proxy/templates/location/proxy_basic.conf.j2' %}
{% set location = '^~ /cool/' %}
{% include 'roles/nginx-docker-reverse-proxy/templates/location/proxy_basic.conf.j2' %}
}

View File

@ -0,0 +1,3 @@
domains:
canonical:
- "collabora.{{ primary_domain }}"

View File

@ -0,0 +1,2 @@
---
application_id: collabora

View File

@ -16,6 +16,8 @@ csp:
flags:
script-src-elem:
unsafe-inline: true
script-src:
unsafe-inline: true
style-src:
unsafe-inline: true
domains:

View File

@ -25,7 +25,7 @@ services:
interval: 1m
timeout: 10s
retries: 3
{% if bridges | bool %}
{% if bridges | length > 0 %}
{% include 'templates/docker/container/depends-on-also-database.yml.j2' %}
{% for item in bridges %}
mautrix-{{item.bridge_name}}:

View File

@ -1,6 +1,36 @@
# Administration
# Radical Erase of Setup
## Moodle Docker Directory Path
Moodle lives in: ``cd /opt/docker/moodle``
## Upgrade
```bash
docker exec --user daemon moodle php /opt/bitnami/moodle/admin/cli/upgrade.php --non-interactive
```
## Delete Cache
To clean the cache execute:
```bash
docker exec --user daemon moodle php /opt/bitnami/moodle/admin/cli/purge_caches.php
docker exec --user root moodle rm -rf \
/bitnami/moodledata/cache/* \
/bitnami/moodledata/localcache/* \
/bitnami/moodledata/temp/* \
/bitnami/moodledata/sessions/*
docker restart moodle
```
## CLI
A detailled Guid how to use the CLI in moodle you will find [here](https://docs.moodle.org/500/de/Administration_%C3%BCber_Kommandozeile).
## General Administration Tasks
### Radical Erase of Setup
To manually erase the full moodle setup inkluding all data execute:
**CLI:**
@ -24,5 +54,5 @@ DROP DATABASE IF EXISTS moodle;
to delete all data in the database related to this role.
# Virgin Setup
### Virgin Setup
After the installation you can rerun this role to create a fresh setup of Moodle.

View File

@ -19,4 +19,5 @@ galaxy_info:
documentation: "https://s.veen.world/cymais"
logo:
class: "fa-solid fa-graduation-cap"
dependencies: []
run_after:
- "docker-keycloak"

View File

@ -12,6 +12,26 @@
- include_tasks: "{{ playbook_dir }}/roles/docker-compose/tasks/create-files.yml"
- name: Wait until the Moodle container is healthy
shell: docker inspect --format '{% raw %}{{.State.Health.Status}}{% endraw %}' {{ container_name }}
register: health_check
until: health_check.stdout.strip() == "healthy"
retries: 120
delay: 5
- name: "Include ownership settings tasks for moodle"
include_tasks: ownership.yml
- name: "Configure OIDC login for Moodle if enabled"
include_tasks: oidc.yml
when: applications | is_feature_enabled('oidc',application_id)
- name: Run Moodle system check
command: >
docker exec --user {{ bitnami_user }} {{ container_name }}
php /opt/bitnami/moodle/admin/cli/checks.php
register: moodle_checks
changed_when: false
failed_when: >
moodle_checks.rc != 0 or
"OK: All" not in moodle_checks.stdout

View File

@ -1,24 +1,60 @@
---
- name: "Upgrade Moodle to apply OIDC plugin"
command: "docker exec {{ container_name }} php admin/cli/upgrade.php --non-interactive"
- name: Check if OIDC plugin is present in container
command: >
docker exec --user root {{ container_name }} test -d {{ bitnami_oidc_plugin_dir }}
register: oidc_plugin_check
ignore_errors: true
changed_when: false
- name: Fail if plugin not present to avoid broken auth
fail:
msg: "OIDC plugin not present skipping configuration"
when: oidc_plugin_check.rc != 0
#- name: "Upgrade Moodle to apply OIDC plugin"
# command: "docker exec --user {{ bitnami_user }} {{ container_name }} php /opt/bitnami/moodle/admin/cli/upgrade.php --non-interactive"
#
#- name: Clear Moodle cache
# command: >
# docker exec --user {{ bitnami_user }} {{ container_name }} php /opt/bitnami/moodle/admin/cli/purge_caches.php
- name: "Set Moodle OIDC configuration via CLI"
loop:
- { name: "issuerurl", value: "{{ oidc.client.issuer_url }}" }
- { name: "clientid", value: "{{ oidc.client.id }}" }
- { name: "clientsecret", value: "{{ oidc.client.secret }}" }
- { name: "authmethod", value: "oidc" }
- { name: "loginflow", value: "authorization_code" }
- { name: "idpname", value: "Keycloak" }
- { name: "scopes", value: "openid profile email" }
- { name: "authenticationendpoint", value: "{{ oidc.client.authorize_url }}" }
- { name: "tokenendpoint", value: "{{ oidc.client.token_url }}" }
- { name: "userinfoendpoint", value: "{{ oidc.client.user_info_url }}" }
- { name: "idptype", value: 3 }
- { name: "clientauthmethod", value: 1 }
- { name: "clientid", value: "{{ oidc.client.id }}" }
- { name: "clientsecret", value: "{{ oidc.client.secret }}" }
- { name: "opname", value: "{{oidc.button_text}}" }
- { name: "oidcscope", value: "openid profile email" }
- { name: "authendpoint", value: "{{ oidc.client.authorize_url }}" }
- { name: "tokenendpoint", value: "{{ oidc.client.token_url }}" }
- { name: "bindingusernameclaim", value: "{{ oidc.attributes.username }}" }
- { name: "single_sign_off", value: 1 } # Logs the user out from the IDP
- { name: "logouturi", value: "{{ oidc.client.logout_url }}" }
- { name: "icon", value: "moodle:t/lock" }
- { name: "field_map_firstname", value: "{{ oidc.attributes.given_name }}" }
- { name: "field_lock_firstname", value: "locked" }
- { name: "field_map_lastname", value: "{{ oidc.attributes.family_name }}" }
- { name: "field_lock_lastname", value: "locked" }
- { name: "field_map_email", value: "locked" }
#- { name: "showloginform", value: 0 } # Deactivate if OIDC is active
- { name: "alternateloginurl", value: "{{ web_protocol }}://{{ domains | get_domain(application_id) }}/auth/oidc/" }
loop_control:
label: "{{ item.name }}"
command: >
docker exec {{ container_name }} php admin/cli/cfg.php --component=auth_oidc
docker exec --user {{ bitnami_user }} {{ container_name }} php /opt/bitnami/moodle/admin/cli/cfg.php --component=auth_oidc
--name={{ item.name }} --set="{{ item.value }}"
- name: "Enable OIDC login"
command: "docker exec {{ container_name }} php admin/cli/cfg.php --name=auth --set=oidc"
command: "docker exec --user {{ bitnami_user }} {{ container_name }} php /opt/bitnami/moodle/admin/cli/cfg.php --name=auth --set=oidc"
- name: Set auth = 'oidc' for all users except guest
shell: >
docker exec {{ database_instance }} mariadb -u {{ database_username }} -p{{ database_password }}
-e "UPDATE moodle.mdl_user SET auth = 'oidc' WHERE username != 'guest';"
args:
executable: /bin/bash
#- name: Prevent Account Creation
# command: docker exec --user {{ bitnami_user }} {{ container_name }} php /opt/bitnami/moodle/admin/cli/cfg.php --name=authpreventaccountcreation --set=1

View File

@ -0,0 +1,19 @@
# This file sets the correct ownership rights for Moodle volumes
- name: Set ownership and permissions on Moodle directories
vars:
moodle_dirs:
- "{{ bitnami_code_dir }}"
- "{{ bitnami_data_dir }}"
block:
- name: Ensure ownership is correct
command: "docker exec --user root {{ container_name }} chown -R {{ bitnami_user_group }} {{ item }}"
loop: "{{ moodle_dirs }}"
- name: Set directory permissions (770)
command: "docker exec --user root {{ container_name }} find {{ item }} -type d -exec chmod 770 {} \\;"
loop: "{{ moodle_dirs }}"
- name: Set file permissions (660)
command: "docker exec --user root {{ container_name }} find {{ item }} -type f -exec chmod 660 {} \\;"
loop: "{{ moodle_dirs }}"

View File

@ -1,14 +1,16 @@
FROM bitnami/moodle:{{ applications[application_id].version }}
{% if applications | is_feature_enabled('oidc',application_id) %}
# Install git (required to clone the OIDC plugin)
USER root
RUN install_packages git unzip
# Clone the Microsoft OIDC plugin into Moodle's auth directory
RUN git clone https://github.com/microsoft/moodle-auth_oidc.git \
/opt/bitnami/moodle/auth/oidc && \
chown -R www-data:www-data /opt/bitnami/moodle/auth/oidc
USER 1001
{% endif %}
{% if applications | is_feature_enabled('oidc', application_id) %}
RUN install_packages unzip curl jq \
&& VERSION=$(curl -s https://api.github.com/repos/microsoft/moodle-auth_oidc/tags \
| jq -r '.[].name' \
| grep v{{ applications[application_id].version }} \
| sort -Vr \
| head -n1) \
&& echo "Using version $VERSION" \
&& curl -L -o /tmp/oidc.zip https://github.com/microsoft/moodle-auth_oidc/archive/refs/tags/${VERSION}.zip \
&& unzip /tmp/oidc.zip -d /tmp \
&& mv /tmp/moodle-auth_oidc-* {{ bitnami_oidc_plugin_dir }} \
&& chown -R {{ bitnami_user_group }} {{ bitnami_oidc_plugin_dir }} \
&& rm -rf /tmp/oidc.zip
{% endif %}

View File

@ -11,8 +11,8 @@ services:
- 127.0.0.1:{{ports.localhost.http[application_id]}}:8080
{% include 'roles/docker-compose/templates/services/base.yml.j2' %}
volumes:
- 'moodle:/bitnami/moodle'
- 'data:/bitnami/moodledata'
- 'code:{{ bitnami_code_link }}'
- 'data:{{ bitnami_data_dir }}'
healthcheck:
test: ["CMD", "bash", "-c", "exec 3<>/dev/tcp/localhost/8080 && echo -e 'GET / HTTP/1.1\\r\\nHost: localhost\\r\\nConnection: close\\r\\n\\r\\n' >&3 && cat <&3 | grep -q 'HTTP/1.1'"]
interval: 30s
@ -22,7 +22,7 @@ services:
{% include 'templates/docker/container/networks.yml.j2' %}
{% include 'templates/docker/compose/volumes.yml.j2' %}
moodle:
code:
data:
{% include 'templates/docker/compose/networks.yml.j2' %}

View File

@ -1,10 +1,7 @@
MOODLE_DATABASE_HOST={{database_host}}
MOODLE_DATABASE_PORT_NUMBER={{database_port}}
MOODLE_DATABASE_USER={{database_username}}
MOODLE_DATABASE_NAME={{database_name}}
MOODLE_DATABASE_PASSWORD={{database_password}}
ALLOW_EMPTY_PASSWORD=no
# General
MOODLE_SITE_NAME="{{applications[application_id].site_titel}}"
MOODLE_HOST="{{ domains | get_domain(application_id) }}"
MOODLE_SSLPROXY=yes
MOODLE_REVERSE_PROXY=yes
MOODLE_USERNAME={{applications[application_id].users.administrator.username}}
@ -12,8 +9,15 @@ MOODLE_PASSWORD={{applications[application_id].credentials.user_password}}
MOODLE_EMAIL={{applications[application_id].users.administrator.email}}
BITNAMI_DEBUG={% if enable_debug | bool %}true{% else %}false{% endif %}
# Database
MOODLE_DATABASE_HOST={{database_host}}
MOODLE_DATABASE_PORT_NUMBER={{database_port}}
MOODLE_DATABASE_USER={{database_username}}
MOODLE_DATABASE_NAME={{database_name}}
MOODLE_DATABASE_PASSWORD={{database_password}}
MOODLE_HOST={{ system_email.host }}
# SMTP
MOODLE_SMTP_HOST={{ system_email.host }}
MOODLE_SMTP_PORT_NUMBER={{ system_email.port }}
MOODLE_SMTP_USER={{ users['no-reply'].email }}
MOODLE_SMTP_PASSWORD={{ users['no-reply'].mailu_token }}

View File

@ -3,20 +3,23 @@ users:
administrator:
username: "{{users.administrator.username}}"
email: "{{users.administrator.email}}"
version: "latest"
version: "4.5" # Latest LTS - Necessary for OIDC
features:
matomo: true
css: false
portfolio_iframe: false
central_database: true
oidc: false
oidc: true
csp:
flags:
script-src-elem:
unsafe-inline: true
unsafe-eval: true
script-src:
unsafe-eval: true
style-src:
unsafe-inline: true
unsafe-eval: true
whitelist:
font-src:
- "data:"

View File

@ -1,4 +1,10 @@
---
application_id: "moodle"
database_type: "mariadb"
container_name: "{{ application_id }}"
application_id: "moodle"
database_type: "mariadb"
container_name: "{{ application_id }}"
bitnami_code_link: "/bitnami/moodle"
bitnami_code_dir: "/opt{{bitnami_code_link}}"
bitnami_data_dir: "/bitnami/moodledata"
bitnami_oidc_plugin_dir: "{{ bitnami_code_dir }}/auth/oidc"
bitnami_user: "daemon"
bitnami_user_group: "{{ bitnami_user }}:{{ bitnami_user }}"

View File

@ -0,0 +1,2 @@
# Todo
- Implement Collabora and Talk Supper . [See](https://www.youtube.com/watch?v=7cRmvTyt1ik)

View File

@ -28,3 +28,7 @@ galaxy_info:
documentation: "https://s.veen.world/cymais/docker-nextcloud"
logo:
class: "fa-solid fa-cloud"
run_after:
- docker-collabora
- docker-keycloak
- docker-mastodon

View File

@ -20,6 +20,28 @@ services:
{% include 'templates/docker/container/networks.yml.j2' %}
ipv4_address: 192.168.102.69
# @Todo activate
#nc-talk:
# image: nextcloud/aio-talk:latest
# container_name: talk_hpb
# hostname: hpb_yt
# restart: unless-stopped
# init: true
# ports:
# - 3478:3478/tcp #TURN TCP
# - 3478:3478/udp #TURN UDP
# - 8181:8081/tcp #Signaling
# environment:
# - NC_DOMAIN=cloud.yourdomain.tld
# - TALK_HOST=signaling.yourdomain.tld
# - TURN_SECRET=${TURN_SECRET}
# - SIGNALING_SECRET=${SIGNALING_SECRET}
# - TZ=Europe/Berlin
# - TALK_PORT=3478
# - INTERNAL_SECRET=${INTERNAL_SECRET}
# networks:
# - nxnetwork_yt
web:
image: nginx:alpine
container_name: {{applications.nextcloud.container.proxy}}

View File

@ -1,4 +1,4 @@
# This is the nginx configuration file for the proxy server
{# This is the nginx configuration file for the proxy server #}
server
{

View File

@ -36,6 +36,7 @@ legacy_login_mask:
container:
application: "nextcloud-application" # Nextcloud application container name
proxy: "nextcloud-web" # Nextcloud Proxy Container Name
collabora: "nextcloud-collabora"
performance:
php:
memory_limit: "{{ ((ansible_memtotal_mb | int) / 30)|int }}M" # Dynamic set memory limit

View File

@ -26,3 +26,4 @@ galaxy_info:
class: "fa-solid fa-database"
run_after:
- docker-matomo
- docker-keycloak

View File

@ -26,3 +26,4 @@ galaxy_info:
run_after:
- docker-ldap
- docker-matomo
- docker-keycloak

View File

@ -27,4 +27,5 @@ galaxy_info:
class: "fa-solid fa-database"
run_after:
- docker-mariadb
- docker-matomo
- docker-matomo
- docker-keycloak

View File

@ -28,4 +28,7 @@ galaxy_info:
documentation: "https://s.veen.world/cymais"
logo:
class: "fa-solid fa-tasks"
dependencies: []
run_after:
- docker-postgres
- docker-matomo
- docker-keycloak

View File

@ -25,4 +25,7 @@ galaxy_info:
documentation: "https://s.veen.world/cymais"
logo:
class: "fa-solid fa-link"
dependencies: []
run_after:
- docker-mariadb
- docker-matomo
- docker-keycloak

View File

@ -63,7 +63,7 @@
(current_play_domains |
combine(
current_play_domain_mappings_redirect |
items2dict(key_name='target', value_name='source'),
items2dict(key_name='source', value_name='source'),
recursive=True
)) |
generate_all_domains(

View File

@ -86,6 +86,17 @@ class TestDomainMappings(unittest.TestCase):
]
result = self.filter.domain_mappings(apps, self.primary)
self.assertCountEqual(result, expected)
def test_multiple_aliases(self):
apps = {
'app1': {'domains': {'aliases': ['a1.com','a2.com']}}
}
expected = [
{'source': 'a1.com', 'target': 'app1.example.com'},
{'source': 'a2.com', 'target': 'app1.example.com'}
]
result = self.filter.domain_mappings(apps, self.primary)
self.assertCountEqual(result, expected)
def test_invalid_aliases_type(self):
apps = {