Files
computer-playbook/roles/web-app-listmonk/tasks/main.yml
Kevin Veen-Birkenbach 986f959696 Refactor webserver proxy variables and fix BigBlueButton deployment behavior
Refactor proxy/webserver configuration variables to a consistent webserver_* naming scheme across roles. Replace legacy variables like proxy_extra_configuration, client_max_body_size, vhost_flavour, location_ws and ws_port with webserver_extra_configuration, webserver_client_max_body_size, webserver_vhost_flavour, webserver_websocket_location and webserver_websocket_port. Update NGINX vhost and location templates (html, upload, ws, basic, ws_generic) as well as callers (sys-front-inj-all, sys-stk-front-proxy, various web-app-* and web-svc-* roles) to use the new naming.

Tighten docker-compose Git repository handling by making docker_git_repository_pull depend on docker_git_repository_address being defined, a string and non-empty. This avoids accidental Git operations when the repository address is unset or of the wrong type.

Refactor the BigBlueButton role structure and fix deployment bugs: introduce 01_core.yml to orchestrate docker/proxy setup, database seeding, websocket map deployment, docker-compose overrides and admin/bootstrap logic in a single once-executed entrypoint. Rename supporting task files (02_docker-compose.yml, 03_administrator.yml, 04_dependencies.yml) and update tasks/main.yml to delegate via include_tasks with run_once_web_app_bigbluebutton. Improve Greenlight admin creation behavior by treating the 'Email has already been taken' error as a non-fatal, unchanged outcome and running user:set_admin_role as a fallback, both for the primary password and the OIDC starred-password path.

Also standardize vhost flavour selection for services like Mailu, Discourse, CDN, Collabora, Coturn, OnlyOffice, Simpleicons and web-svc-logout by explicitly passing webserver_vhost_flavour where needed and aligning client_max_body_size and websocket configuration with the new webserver_* variables.

Reference: ChatGPT conversation https://chatgpt.com/share/6931c530-bba8-800f-9997-dd61dc1d497b
2025-12-04 18:31:09 +01:00

86 lines
2.7 KiB
YAML

---
- name: "load docker, db and proxy for {{ application_id }}"
include_role:
name: sys-stk-full-stateful
vars:
docker_compose_flush_handlers: false
webserver_extra_configuration: >-
{% if not LISTMONK_PUBLIC_API_ENABLED | bool %}
{{ lookup('file', '{{ playbook_dir }}/roles/web-app-listmonk/files/deactivate-public-api.conf') }}
{% else %}
""
{% endif %}
- name: add config.toml
template:
src: "config.toml.j2"
dest: "{{ LISTMONK_CONFIG_HOST }}"
notify: docker compose up
- meta: flush_handlers
- name: Check if listmonk database is already initialized
command: '{{ docker_compose_command_exec }} -T {{ database_host }} psql -U {{ database_username }} -d {{ database_name }} -c "\dt"'
register: db_tables
changed_when: false
failed_when: false
- name: Run Listmonk setup only if DB is empty
command:
cmd: docker compose run -T --rm application sh -c "yes | ./listmonk --install"
chdir: "{{ docker_compose.directories.instance }}"
when: "'No relations found.' in db_tables.stdout"
- name: "Listmonk | run DB/schema upgrade (non-interactive)"
ansible.builtin.shell: |
set -o pipefail
echo "y" | docker compose run -T application ./listmonk --upgrade
args:
chdir: "{{ docker_compose.directories.instance }}"
when: MODE_UPDATE | bool
- name: Build OIDC settings JSON
set_fact:
oidc_settings_json: >-
{{ {
"enabled": True,
"client_id": OIDC.CLIENT.ID,
"provider_url": OIDC.CLIENT.ISSUER_URL,
"client_secret": OIDC.CLIENT.SECRET
} | to_json }}
- name: Update administrator email and password login in Listmonk (as superuser)
shell: |
docker exec -i {{ database_host }} psql \
-U {{ database_username }} \
-v ON_ERROR_STOP=1 \
-d {{ database_name }} << 'EOSQL'
UPDATE users
SET email = '{{ users.administrator.email }}',
password_login = {{ 'false' if applications | get_app_conf(application_id, 'features.oidc', True) else 'true' }}
WHERE username = 'administrator';
EOSQL
args:
executable: /bin/bash
- name: Apply all Listmonk settings
shell: |
docker exec -i {{ database_host }} psql \
-U {{ database_username }} \
-v ON_ERROR_STOP=1 \
-d {{ database_name }} << 'EOSQL'
UPDATE settings
SET value = '{{ item.value }}'::jsonb
WHERE key = '{{ item.key }}';
EOSQL
args:
executable: /bin/bash
loop: "{{ LISTMONK_SETTINGS }}"
loop_control:
label: "{{ item.key }}"
when: (item.when | default(true)) | bool
no_log: "{{ MASK_CREDENTIALS_IN_LOGS | bool }}"
async: "{{ ASYNC_TIME if ASYNC_ENABLED | bool else omit }}"
poll: "{{ ASYNC_POLL if ASYNC_ENABLED | bool else omit }}"