From f5e3a12f9616fa7d6e9b4d06675039e8104a7ce0 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 23 May 2020 19:04:51 +0200 Subject: collabora/code: config files are now managed by ansible --- .../collabora/code/contrib/extract-lolwsdxml.sh | 27 ++++ roles/apps/collabora/code/defaults/main.yml | 10 +- roles/apps/collabora/code/tasks/main.yml | 12 +- .../code/templates/config/loolwsd.4.2.1.2.xml.j2 | 154 +++++++++++++++++++++ .../collabora/code/templates/nginx-vhost.conf.j2 | 8 +- roles/apps/collabora/code/templates/pod.yml.j2 | 4 - 6 files changed, 201 insertions(+), 14 deletions(-) create mode 100755 roles/apps/collabora/code/contrib/extract-lolwsdxml.sh create mode 100644 roles/apps/collabora/code/templates/config/loolwsd.4.2.1.2.xml.j2 (limited to 'roles') diff --git a/roles/apps/collabora/code/contrib/extract-lolwsdxml.sh b/roles/apps/collabora/code/contrib/extract-lolwsdxml.sh new file mode 100755 index 00000000..ab4e5fb4 --- /dev/null +++ b/roles/apps/collabora/code/contrib/extract-lolwsdxml.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi +VERSION="$1" + +IMAGE_TAG="$VERSION" +IMAGE_NAME="collabora/code" +CONF_D=$(realpath "${BASH_SOURCE%/*}/../templates/config") +CONTAINER_NAME="collabora-code-loolwsd.xml-extractor" + +sudo docker rm "$CONTAINER_NAME" > /dev/null 2>&1 + +set -e +sudo docker create --name "$CONTAINER_NAME" "$IMAGE_NAME:$IMAGE_TAG" /bin/true +sudo docker cp --archive=false "$CONTAINER_NAME:/etc/loolwsd/loolwsd.xml" - | tar -xO loolwsd.xml > "$CONF_D/loolwsd.$VERSION.xml.j2" +sudo docker rm "$CONTAINER_NAME" + +echo "" +echo "File extraction was sucessful! Now snyc the config file with existing ones." +echo "" +echo "you might also want to delete the image:" +echo "" +echo " sudo docker rmi '$IMAGE_NAME:$IMAGE_TAG'" +echo "" diff --git a/roles/apps/collabora/code/defaults/main.yml b/roles/apps/collabora/code/defaults/main.yml index f17054ed..2f025db5 100644 --- a/roles/apps/collabora/code/defaults/main.yml +++ b/roles/apps/collabora/code/defaults/main.yml @@ -5,7 +5,9 @@ collabora_code_base_path: /srv/collabora/code # example: # version: 4.0.6.1 # port: 8200 -# hostnames: -# - office.example.com -# admin_user: admin -# admin_password: S3cret +# hostname: office.example.com +# admin: +# username: admin +# password: S3cret +# backend_storages: +# - cloud.example.com diff --git a/roles/apps/collabora/code/tasks/main.yml b/roles/apps/collabora/code/tasks/main.yml index ce88fe0d..e283035b 100644 --- a/roles/apps/collabora/code/tasks/main.yml +++ b/roles/apps/collabora/code/tasks/main.yml @@ -4,8 +4,15 @@ file: path: "{{ collabora_code_base_path }}/{{ item }}/config" state: directory + mode: 0750 -## TODO: render config.xml +- name: generate configuration file + loop: "{{ collabora_code_instances | dict2items }}" + loop_control: + label: "{{ item.key }}" + template: + src: "config/loolwsd.{{ item.value.version }}.xml.j2" + dest: "{{ collabora_code_base_path }}/{{ item.key }}/config/loolwsd.xml" - name: generate pod manifests loop: "{{ collabora_code_instances | dict2items }}" @@ -25,4 +32,5 @@ name: "collabora-code-{{ item.key }}" content: "{{ lookup('template', 'nginx-vhost.conf.j2') }}" acme: true - hostnames: "{{ item.value.hostnames }}" + hostnames: + - "{{ item.value.hostname }}" diff --git a/roles/apps/collabora/code/templates/config/loolwsd.4.2.1.2.xml.j2 b/roles/apps/collabora/code/templates/config/loolwsd.4.2.1.2.xml.j2 new file mode 100644 index 00000000..04269bd9 --- /dev/null +++ b/roles/apps/collabora/code/templates/config/loolwsd.4.2.1.2.xml.j2 @@ -0,0 +1,154 @@ + + + + + + de_DE en_GB en_US es_ES fr_FR it nl pt_BR pt_PT ru + + + + + {{ item.value.hostname }} + + + + 1 + + 4 + https://app.vereign.com + false + 3600 + + + 30 + 300 + false + 0 + 8000 + 0 + 0 + 100 + 100 + + + + 120 + 900 + + + loleaflet.html + + + true + warning + false + + /var/log/loolwsd.log + never + timestamp + true + 10 days + 10 + true + false + + + false + 82589933 + + + + false + + + + + + + + false + + + + + + all + any + + + 192\.168\.[0-9]{1,3}\.[0-9]{1,3} + ::ffff:192\.168\.[0-9]{1,3}\.[0-9]{1,3} + 127\.0\.0\.1 + ::ffff:127\.0\.0\.1 + ::1 + 172\.17\.[0-9]{1,3}\.[0-9]{1,3} + ::ffff:172\.17\.[0-9]{1,3}\.[0-9]{1,3} + + + + + + true + false + /etc/loolwsd/cert.pem + /etc/loolwsd/key.pem + /etc/loolwsd/ca-chain.cert.pem + + + 1000 + + + + + + + + + true + true + + + + + + + + + + + localhost +{% for backend in item.value.backend_storages %} + {{ backend }} +{% endfor %} + 0 + false + + 900 + + + + localhost + + + + + + + + + + + true + + + true + false + {{ item.value.admin.username }} + {{ item.value.admin.password }} + + + + + + diff --git a/roles/apps/collabora/code/templates/nginx-vhost.conf.j2 b/roles/apps/collabora/code/templates/nginx-vhost.conf.j2 index cec811f9..a14113f0 100644 --- a/roles/apps/collabora/code/templates/nginx-vhost.conf.j2 +++ b/roles/apps/collabora/code/templates/nginx-vhost.conf.j2 @@ -1,7 +1,7 @@ server { listen 80; listen [::]:80; - server_name {{ item.value.hostnames | join(' ') }}; + server_name {{ item.value.hostname }}; include snippets/acmetool.conf; @@ -13,12 +13,12 @@ server { server { listen 443 ssl http2; listen [::]:443 ssl http2; - server_name {{ item.value.hostnames | join(' ') }}; + server_name {{ item.value.hostname }}; include snippets/acmetool.conf; include snippets/tls.conf; - ssl_certificate /var/lib/acme/live/{{ item.value.hostnames[0] }}/fullchain; - ssl_certificate_key /var/lib/acme/live/{{ item.value.hostnames[0] }}/privkey; + ssl_certificate /var/lib/acme/live/{{ item.value.hostname }}/fullchain; + ssl_certificate_key /var/lib/acme/live/{{ item.value.hostname }}/privkey; include snippets/hsts.conf; diff --git a/roles/apps/collabora/code/templates/pod.yml.j2 b/roles/apps/collabora/code/templates/pod.yml.j2 index 8ed092ac..eb771de7 100644 --- a/roles/apps/collabora/code/templates/pod.yml.j2 +++ b/roles/apps/collabora/code/templates/pod.yml.j2 @@ -12,10 +12,6 @@ spec: env: - name: "DONT_GEN_SSL_CERT" value: "1" - - name: "username" - value: "{{ item.value.admin_user }}" - - name: "password" - value: "{{ item.value.admin_password }}" - name: "extra_params" value: "--o:ssl.enable=false --o:ssl.termination=true" volumeMounts: -- cgit v1.2.3