From 628496d022684a541e9f928aaac0b78b3e3d9da7 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sun, 7 Jan 2024 09:30:08 +0200 Subject: [PATCH] Move matrix-bot-honoroit to its own container network --- group_vars/matrix_servers | 41 ++++++++----------- .../matrix-bot-honoroit/defaults/main.yml | 7 +++- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index d3e67e1d4..eec17c2da 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -1873,40 +1873,23 @@ matrix_bot_honoroit_hostname: "{{ matrix_server_fqn_matrix }}" matrix_bot_honoroit_path_prefix: /honoroit -# For consistency with other things hosted at the matrix FQN, we adjust the metrics endpoint -# so that metrics would be served at `/metrics/SERVICE_NAME`, and not at the default path for the role (`PREFIX/metrics`). -matrix_bot_honoroit_container_labels_traefik_metrics_path: /metrics/honoroit - -matrix_bot_honoroit_systemd_required_services_list: | +matrix_bot_honoroit_systemd_required_services_list_auto: | {{ - ['docker.service'] + matrix_addons_homeserver_systemd_services_list + - ([devture_postgres_identifier ~ '.service'] if devture_postgres_enabled else []) - + - (['matrix-synapse.service'] if matrix_synapse_enabled else []) - + - (['matrix-nginx-proxy.service'] if matrix_nginx_proxy_enabled else []) + ([devture_postgres_identifier ~ '.service'] if devture_postgres_enabled and matrix_bot_honoroit_database_hostname == devture_postgres_connection_hostname else []) }} -# Postgres is the default, except if not using internal Postgres server -matrix_bot_honoroit_database_engine: "{{ 'postgres' if devture_postgres_enabled else 'sqlite' }}" -matrix_bot_honoroit_database_hostname: "{{ devture_postgres_connection_hostname if devture_postgres_enabled else '' }}" -matrix_bot_honoroit_database_password: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'honoroit.bot.db', rounds=655555) | to_uuid }}" -matrix_bot_honoroit_container_image_self_build: "{{ matrix_architecture not in ['amd64', 'arm64'] }}" +matrix_bot_honoroit_container_network: "{{ matrix_addons_container_network }}" -matrix_bot_honoroit_container_network: "{{ matrix_docker_network if matrix_playbook_reverse_proxy_type == 'playbook-managed-nginx' else 'matrix-bot-honoroit' }}" - -# For now, we attach this to the matrix-nginx-proxy network (unless that's the same network as the main one for us), -# because that's where the homeserver is expected to be accessed from. -# In the future, this will need to be redone. matrix_bot_honoroit_container_additional_networks: | {{ ( - ([matrix_playbook_reverse_proxyable_services_additional_network] if matrix_playbook_reverse_proxyable_services_additional_network else []) + ([] if matrix_addons_homeserver_container_network == '' else [matrix_addons_homeserver_container_network]) + - ([matrix_nginx_proxy_container_network] if matrix_nginx_proxy_enabled and matrix_bot_honoroit_container_network != matrix_nginx_proxy_container_network else []) + ([devture_postgres_container_network] if (devture_postgres_enabled and matrix_bot_honoroit_database_hostname == devture_postgres_connection_hostname and matrix_bot_honoroit_container_network != devture_postgres_container_network) else []) + - ([devture_postgres_container_network] if devture_postgres_enabled and devture_postgres_container_network != matrix_bot_honoroit_container_network else []) + ([matrix_playbook_reverse_proxyable_services_additional_network] if matrix_playbook_reverse_proxyable_services_additional_network and matrix_mautrix_facebook_container_labels_traefik_enabled else []) ) | unique }} @@ -1915,6 +1898,16 @@ matrix_bot_honoroit_container_labels_traefik_docker_network: "{{ matrix_playbook matrix_bot_honoroit_container_labels_traefik_entrypoints: "{{ devture_traefik_entrypoint_primary }}" matrix_bot_honoroit_container_labels_traefik_tls_certResolver: "{{ devture_traefik_certResolver_primary }}" +# For consistency with other things hosted at the matrix FQN, we adjust the metrics endpoint +# so that metrics would be served at something like `/metrics/SERVICE_NAME`, and not at the default path for the role (`PREFIX/metrics`). +matrix_bot_honoroit_container_labels_traefik_metrics_path: "{{ matrix_metrics_exposure_path_prefix }}/honoroit" + +# Postgres is the default, except if not using internal Postgres server +matrix_bot_honoroit_database_engine: "{{ 'postgres' if devture_postgres_enabled else 'sqlite' }}" +matrix_bot_honoroit_database_hostname: "{{ devture_postgres_connection_hostname if devture_postgres_enabled else '' }}" +matrix_bot_honoroit_database_password: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'honoroit.bot.db', rounds=655555) | to_uuid }}" +matrix_bot_honoroit_container_image_self_build: "{{ matrix_architecture not in ['amd64', 'arm64'] }}" + ###################################################################### # # /matrix-bot-honoroit diff --git a/roles/custom/matrix-bot-honoroit/defaults/main.yml b/roles/custom/matrix-bot-honoroit/defaults/main.yml index 794cf841c..32a4c5e3a 100644 --- a/roles/custom/matrix-bot-honoroit/defaults/main.yml +++ b/roles/custom/matrix-bot-honoroit/defaults/main.yml @@ -32,7 +32,7 @@ matrix_bot_honoroit_data_path: "{{ matrix_bot_honoroit_base_path }}/data" matrix_bot_honoroit_data_store_path: "{{ matrix_bot_honoroit_data_path }}/store" # The base container network. It will be auto-created by this role if it doesn't exist already. -matrix_bot_honoroit_container_network: matrix-bot-honoroit +matrix_bot_honoroit_container_network: "" # A list of additional container networks that the container would be connected to. # The role does not create these networks, so make sure they already exist. @@ -83,7 +83,10 @@ matrix_bot_honoroit_container_labels_additional_labels: '' matrix_bot_honoroit_container_extra_arguments: [] # List of systemd services that matrix-bot-honoroit.service depends on -matrix_bot_honoroit_systemd_required_services_list: ['docker.service'] +matrix_bot_honoroit_systemd_required_services_list: "{{ matrix_bot_honoroit_systemd_required_services_list_default + matrix_bot_honoroit_systemd_required_services_list_auto + matrix_bot_honoroit_systemd_required_services_list_custom }}" +matrix_bot_honoroit_systemd_required_services_list_default: ['docker.service'] +matrix_bot_honoroit_systemd_required_services_list_auto: [] +matrix_bot_honoroit_systemd_required_services_list_custom: [] # List of systemd services that matrix-bot-honoroit.service wants matrix_bot_honoroit_systemd_wanted_services_list: []