diff --git a/plugins/lookup/email.py b/plugins/lookup/email.py index b42b88d661..5781935f35 100644 --- a/plugins/lookup/email.py +++ b/plugins/lookup/email.py @@ -13,7 +13,7 @@ from plugins.lookup.domain import LookupModule as DomainLookup from plugins.lookup.users import LookupModule as UsersLookup from utils.domains.primary_domain import get_domain from utils.mail.provider import deployed_roles, resolve_active_provider -from utils.roles.entity.name import get_entity_name +from utils.roles.entity.name import entity_name SYSTEM_EMAIL_PREFIX = "SYSTEM_EMAIL_" @@ -284,7 +284,7 @@ class LookupModule(LookupBase): either being named here. """ services = self._provider_services(variables) - entity = get_entity_name(self._mail_provider(variables)) + entity = entity_name(self._mail_provider(variables)) entry = services.get(entity) or {} if not isinstance(entry, dict): return {} diff --git a/roles/svc-ai-agent-broker/meta/networks.yml b/roles/svc-ai-agent-broker/meta/networks.yml index f0eb839753..f2902b6d09 100644 --- a/roles/svc-ai-agent-broker/meta/networks.yml +++ b/roles/svc-ai-agent-broker/meta/networks.yml @@ -1,6 +1,6 @@ --- local: - subnet: 192.168.223.0/24 + subnet: 192.168.81.0/24 overlay: modes: [compose, swarm] topology: shared_net diff --git a/roles/svc-cache-package/meta/services.yml b/roles/svc-cache-package/meta/services.yml index a2e19ae9c6..f199dfbcff 100644 --- a/roles/svc-cache-package/meta/services.yml +++ b/roles/svc-cache-package/meta/services.yml @@ -32,7 +32,7 @@ package: pids_limit: 512 ports: local: - http: 8095 + http: 8099 internal: http: 8081 blobstore_max: 40g diff --git a/roles/svc-net-tor-smtp/files/Dockerfile b/roles/svc-net-tor-smtp/files/Dockerfile index c6f43f7b3a..a47392f38c 100644 --- a/roles/svc-net-tor-smtp/files/Dockerfile +++ b/roles/svc-net-tor-smtp/files/Dockerfile @@ -1,10 +1,8 @@ -# Tor SMTP gateway: receives SMTP from the active mail provider and relays each -# .onion recipient through Tor's SOCKS5 listener. aiosmtpd is the SMTP server, -# PySocks the SOCKS client โ€” both pinned so the image is reproducible. ARG PY_BASE FROM ${PY_BASE} -RUN pip install --no-cache-dir "aiosmtpd==1.4.6" "PySocks==1.7.1" +COPY requirements.txt /app/requirements.txt +RUN pip install --no-cache-dir -r /app/requirements.txt COPY tor_smtp_gateway.py /usr/local/bin/tor_smtp_gateway.py diff --git a/roles/svc-net-tor-smtp/files/requirements.txt b/roles/svc-net-tor-smtp/files/requirements.txt new file mode 100644 index 0000000000..c811e413a4 --- /dev/null +++ b/roles/svc-net-tor-smtp/files/requirements.txt @@ -0,0 +1,2 @@ +aiosmtpd==1.4.6 +PySocks==1.7.1 diff --git a/roles/svc-net-tor-smtp/tasks/00_core.yml b/roles/svc-net-tor-smtp/tasks/00_core.yml index fcc5dfab96..3086fb0e3b 100644 --- a/roles/svc-net-tor-smtp/tasks/00_core.yml +++ b/roles/svc-net-tor-smtp/tasks/00_core.yml @@ -14,11 +14,18 @@ vars: network_role_id: "{{ application_id }}" -- name: "๐ŸŽฌ Stage the gateway daemon into the build context" +- name: "๐ŸŽฌ Stage the gateway build context" stack_host_copy: - src: "python/tor_smtp_gateway.py" - dest: "{{ [ lookup('container', application_id, 'directories.instance'), 'tor_smtp_gateway.py' ] | path_join }}" + src: "{{ item.src }}" + dest: "{{ [ lookup('container', application_id, 'directories.instance'), item.dest ] | path_join }}" mode: "0644" + loop: + - src: "python/tor_smtp_gateway.py" + dest: "tor_smtp_gateway.py" + - src: "requirements.txt" + dest: "requirements.txt" + loop_control: + label: "{{ item.dest }}" when: IS_STACK_HOST | bool - name: "๐Ÿšฟ Flush compose handlers (build + up with the daemon present)" diff --git a/roles/web-app-gitlab/files/playwright/playwright.spec.js b/roles/web-app-gitlab/files/playwright/playwright.spec.js index dffc1526e3..5f8149386d 100644 --- a/roles/web-app-gitlab/files/playwright/playwright.spec.js +++ b/roles/web-app-gitlab/files/playwright/playwright.spec.js @@ -67,6 +67,7 @@ test("gitlab: a password-reset request is delivered to the recipient's mailbox", test.skip(!ssoEnabled, "the administrator account is created by the first SSO login"); test.skip(!webmailBaseUrl, "the active mail provider serves no webmail vhost to read from"); expect(adminEmail, "ADMIN_EMAIL must be set").toBeTruthy(); + expect(adminUsername, "ADMIN_USERNAME must be set").toBeTruthy(); expect(adminPassword, "ADMIN_PASSWORD must be set").toBeTruthy(); await runAdminFlow(page); diff --git a/roles/web-app-mailu/tasks/10_oidc_refresh.yml b/roles/web-app-mailu/tasks/10_oidc_refresh.yml index 7ef8b52193..e60280e7e1 100644 --- a/roles/web-app-mailu/tasks/10_oidc_refresh.yml +++ b/roles/web-app-mailu/tasks/10_oidc_refresh.yml @@ -16,13 +16,13 @@ - name: "๐Ÿ”„ Restart Mailu admin so the OIDC provider config is re-fetched (compose)" ansible.builtin.command: "container restart {{ MAILU_ADMIN_CONTAINER_ADDRESS }}" changed_when: true - when: DEPLOYMENT_MODE == 'compose' + when: IS_COMPOSE_MODE - name: "๐Ÿ”„ Restart Mailu admin so the OIDC provider config is re-fetched (swarm)" ansible.builtin.command: "container service update --force {{ lookup('container_service', application_id, 'admin') }}" changed_when: true timeout: "{{ lookup('timeout', 600) | int }}" - when: DEPLOYMENT_MODE == 'swarm' + when: IS_SWARM_MODE - name: "๐Ÿงน Clear the deferred OIDC refresh flag" ansible.builtin.set_fact: diff --git a/roles/web-app-stalwart/files/playwright/env.js b/roles/web-app-stalwart/files/playwright/env.js index 1d0acb39b1..0f7526c9d1 100644 --- a/roles/web-app-stalwart/files/playwright/env.js +++ b/roles/web-app-stalwart/files/playwright/env.js @@ -1,18 +1,18 @@ -const { decodeDotenvQuotedValue } = require("./personas"); +const { requireDotenvValue } = require("./personas"); -const appBaseUrl = decodeDotenvQuotedValue(process.env.APP_BASE_URL || "").replace(/\/+$/, ""); -const webmailBaseUrl = decodeDotenvQuotedValue(process.env.WEBMAIL_BASE_URL || "").replace(/\/+$/, ""); -const canonicalDomain = decodeDotenvQuotedValue(process.env.CANONICAL_DOMAIN || ""); -const oidcIssuerUrl = decodeDotenvQuotedValue(process.env.OIDC_ISSUER_URL || ""); -const adminEmail = decodeDotenvQuotedValue(process.env.ADMIN_EMAIL || ""); -const adminUsername = decodeDotenvQuotedValue(process.env.ADMIN_USERNAME || ""); -const adminPassword = decodeDotenvQuotedValue(process.env.ADMIN_PASSWORD || ""); -const stalwartAdminUsername = decodeDotenvQuotedValue(process.env.STALWART_ADMIN_USERNAME || ""); -const stalwartAdminPassword = decodeDotenvQuotedValue(process.env.STALWART_ADMIN_PASSWORD || ""); -const biberEmail = decodeDotenvQuotedValue(process.env.BIBER_EMAIL || ""); -const biberUsername = decodeDotenvQuotedValue(process.env.BIBER_USERNAME || ""); -const biberPassword = decodeDotenvQuotedValue(process.env.BIBER_PASSWORD || ""); -const mapachePassword = decodeDotenvQuotedValue(process.env.MAPACHE_PASSWORD || ""); +const appBaseUrl = requireDotenvValue(process.env.APP_BASE_URL, "APP_BASE_URL").replace(/\/+$/, ""); +const webmailBaseUrl = requireDotenvValue(process.env.WEBMAIL_BASE_URL, "WEBMAIL_BASE_URL").replace(/\/+$/, ""); +const canonicalDomain = requireDotenvValue(process.env.CANONICAL_DOMAIN, "CANONICAL_DOMAIN"); +const oidcIssuerUrl = requireDotenvValue(process.env.OIDC_ISSUER_URL, "OIDC_ISSUER_URL"); +const adminEmail = requireDotenvValue(process.env.ADMIN_EMAIL, "ADMIN_EMAIL"); +const adminUsername = requireDotenvValue(process.env.ADMIN_USERNAME, "ADMIN_USERNAME"); +const adminPassword = requireDotenvValue(process.env.ADMIN_PASSWORD, "ADMIN_PASSWORD"); +const stalwartAdminUsername = requireDotenvValue(process.env.STALWART_ADMIN_USERNAME, "STALWART_ADMIN_USERNAME"); +const stalwartAdminPassword = requireDotenvValue(process.env.STALWART_ADMIN_PASSWORD, "STALWART_ADMIN_PASSWORD"); +const biberEmail = requireDotenvValue(process.env.BIBER_EMAIL, "BIBER_EMAIL"); +const biberUsername = requireDotenvValue(process.env.BIBER_USERNAME, "BIBER_USERNAME"); +const biberPassword = requireDotenvValue(process.env.BIBER_PASSWORD, "BIBER_PASSWORD"); +const mapachePassword = requireDotenvValue(process.env.MAPACHE_PASSWORD, "MAPACHE_PASSWORD"); const expectedOidcAuthUrl = `${oidcIssuerUrl.replace(/\/$/, "")}/protocol/openid-connect/auth`; diff --git a/roles/web-app-stalwart/meta/services.yml b/roles/web-app-stalwart/meta/services.yml index dfdb29767a..663795e883 100644 --- a/roles/web-app-stalwart/meta/services.yml +++ b/roles/web-app-stalwart/meta/services.yml @@ -45,6 +45,11 @@ stalwart: image: stalwartlabs/stalwart version: "v0.16.24" webui_version: "v1.0.5" + update: + - key: webui_version + type: git_tags + repository: https://github.com/stalwartlabs/webui.git + match: "v" name: stalwart backup: project_hard_restart: true @@ -85,7 +90,7 @@ stalwart: postgres: bond: 1 enabled: true # nocheck: dynamic-flag - shared: "{{ ('svc-db-postgres' in group_names) and (DEPLOYMENT_MODE == 'compose') }}" + shared: "{{ ('svc-db-postgres' in group_names) and (IS_COMPOSE_MODE) }}" image: postgres version: "18" cpus: "0.8" diff --git a/roles/web-app-stalwart/tasks/00_core.yml b/roles/web-app-stalwart/tasks/00_core.yml index a6dd7b16d8..0ef7465eb1 100644 --- a/roles/web-app-stalwart/tasks/00_core.yml +++ b/roles/web-app-stalwart/tasks/00_core.yml @@ -91,8 +91,8 @@ vars: domain: "{{ STALWART_WEBMAIL_DOMAIN }}" http_port: "{{ STALWART_WEBMAIL_HTTP_PORT }}" - webserver_proxy_service_key: "{{ 'webmail' if DEPLOYMENT_MODE == 'swarm' else (application_id | get_entity_name) }}" - proxy_internal_port: "{{ lookup('config', application_id, 'services.webmail.ports.internal.http') if DEPLOYMENT_MODE == 'swarm' else '' }}" + webserver_proxy_service_key: "{{ 'webmail' if IS_SWARM_MODE else (application_id | entity_name) }}" + proxy_internal_port: "{{ lookup('config', application_id, 'services.webmail.ports.internal.http') if IS_SWARM_MODE else '' }}" webserver_vhost_flavour: "basic" - name: "๐Ÿ‘” Stalwart manager-side operations (container exec + provisioning)" diff --git a/roles/web-app-stalwart/tasks/05_tls/activate.yml b/roles/web-app-stalwart/tasks/05_tls/activate.yml index 09e419d72d..4b761cd6ec 100644 --- a/roles/web-app-stalwart/tasks/05_tls/activate.yml +++ b/roles/web-app-stalwart/tasks/05_tls/activate.yml @@ -13,13 +13,13 @@ - name: "๐Ÿ”„ Restart Stalwart to activate the registered certificate (compose)" ansible.builtin.command: "container restart {{ STALWART_CONTAINER }}" changed_when: true - when: DEPLOYMENT_MODE == 'compose' + when: IS_COMPOSE_MODE - name: "๐Ÿ”„ Restart Stalwart to activate the registered certificate (swarm)" ansible.builtin.command: "container service update --force {{ lookup('container_service', application_id, 'stalwart') }}" changed_when: true timeout: "{{ lookup('timeout', 600) | int }}" - when: DEPLOYMENT_MODE == 'swarm' + when: IS_SWARM_MODE - name: "โณ Wait for Stalwart API after the certificate restart" include_tasks: "{{ role_path }}/tasks/01_wait_for_api.yml" diff --git a/roles/web-app-stalwart/tasks/11_oidc_restart.yml b/roles/web-app-stalwart/tasks/11_oidc_restart.yml index c83830a255..fdc5a60c66 100644 --- a/roles/web-app-stalwart/tasks/11_oidc_restart.yml +++ b/roles/web-app-stalwart/tasks/11_oidc_restart.yml @@ -16,13 +16,13 @@ - name: "๐Ÿ”„ Restart Stalwart so OIDC directory changes take effect (compose)" ansible.builtin.command: "container restart {{ STALWART_CONTAINER }}" changed_when: true - when: DEPLOYMENT_MODE == 'compose' + when: IS_COMPOSE_MODE - name: "๐Ÿ”„ Restart Stalwart so OIDC directory changes take effect (swarm)" ansible.builtin.command: "container service update --force {{ lookup('container_service', application_id, 'stalwart') }}" changed_when: true timeout: "{{ lookup('timeout', 600) | int }}" - when: DEPLOYMENT_MODE == 'swarm' + when: IS_SWARM_MODE - name: "โณ Wait for Stalwart API after the OIDC restart" include_tasks: 01_wait_for_api.yml @@ -34,7 +34,7 @@ - name: "๐Ÿ”„ Restart Stalwart until the OIDC directory survives the build" ansible.builtin.shell: >- - {{ ('container restart ' ~ STALWART_CONTAINER) if DEPLOYMENT_MODE == 'compose' + {{ ('container restart ' ~ STALWART_CONTAINER) if IS_COMPOSE_MODE else ('container service update --force ' ~ lookup('container_service', application_id, 'stalwart')) }} && container exec -i {{ STALWART_CONTAINER_ADDRESS }} diff --git a/roles/web-app-stalwart/tasks/12_import_mailu.yml b/roles/web-app-stalwart/tasks/12_import_mailu.yml index 100fd421f2..bafabf60bd 100644 --- a/roles/web-app-stalwart/tasks/12_import_mailu.yml +++ b/roles/web-app-stalwart/tasks/12_import_mailu.yml @@ -1,6 +1,6 @@ --- # include-gated: when: STALWART_IMPORT_MAILU and 'web-app-mailu' in group_names -# and STALWART_ACTIVE_PROVIDER and DEPLOYMENT_MODE == 'compose' +# and STALWART_ACTIVE_PROVIDER and IS_COMPOSE_MODE - name: "๐Ÿ” Resolve the legacy Mailu maildir volume mountpoint" ansible.builtin.command: >- container volume inspect --format "{{ '{{' }} .Mountpoint {{ '}}' }}" diff --git a/roles/web-app-stalwart/tasks/manager_ops.yml b/roles/web-app-stalwart/tasks/manager_ops.yml index 4727bd0c5d..cce7066b99 100644 --- a/roles/web-app-stalwart/tasks/manager_ops.yml +++ b/roles/web-app-stalwart/tasks/manager_ops.yml @@ -7,7 +7,7 @@ ansible.builtin.command: "container restart {{ STALWART_CONTAINER }}_clamav" changed_when: true when: - - DEPLOYMENT_MODE == 'compose' + - IS_COMPOSE_MODE - STALWART_ANTIVIRUS_ENABLED | bool - stalwart_clamav_conf is defined - stalwart_clamav_conf is changed @@ -16,7 +16,7 @@ ansible.builtin.command: "container restart {{ STALWART_CONTAINER }}_webmail" changed_when: true when: - - DEPLOYMENT_MODE == 'compose' + - IS_COMPOSE_MODE - STALWART_SSO_ENABLED | bool - stalwart_webmail_conf is defined - stalwart_webmail_conf is changed @@ -43,4 +43,4 @@ - STALWART_IMPORT_MAILU | bool - "'web-app-mailu' in group_names" - STALWART_ACTIVE_PROVIDER | bool - - DEPLOYMENT_MODE == 'compose' + - IS_COMPOSE_MODE diff --git a/roles/web-app-stalwart/templates/compose.yml.j2 b/roles/web-app-stalwart/templates/compose.yml.j2 index b3e80ff202..0184a29fa1 100644 --- a/roles/web-app-stalwart/templates/compose.yml.j2 +++ b/roles/web-app-stalwart/templates/compose.yml.j2 @@ -18,7 +18,7 @@ {% else %} {{ lookup('container_ports', ['stalwart', 'http', DOCKER_BIND_HOST]) | indent(4) }} {% endif %} - environment: + environment: # nocheck: compose-environment-from-env-file this role sets no docker_compose_env, so a single templates/env.j2 would also be the env_file of the webmail and clamav containers, which must not receive the recovery admin credential STALWART_RECOVERY_ADMIN: "{{ STALWART_ADMIN_USER }}:{{ STALWART_ADMIN_PASSWORD }}" {{ lookup('container_volumes', service_name) | indent(4) }} {{ lookup('container_depends_on', application_id) | indent(4) }} @@ -32,7 +32,7 @@ {{ lookup('container_extra_hosts') | indent(4) }} {{ lookup('container_healthcheck', service_name) | indent(4) }} {{ lookup('container_ports', ['webmail', 'http', DOCKER_BIND_HOST]) | indent(4) }} - environment: + environment: # nocheck: compose-environment-from-env-file roundcube-only keys; this role sets no docker_compose_env, so a single templates/env.j2 would also be the env_file of the stalwart and clamav containers, which must not receive the OIDC client secret ROUNDCUBEMAIL_DEFAULT_HOST: "ssl://stalwart" ROUNDCUBEMAIL_DEFAULT_PORT: "993" ROUNDCUBEMAIL_SMTP_SERVER: "ssl://stalwart" @@ -51,7 +51,7 @@ {{ lookup('compose_only', 'container_name', STALWART_CONTAINER ~ '_clamav') }} {{ lookup('container_image', application_id, service_name) }} {% include 'roles/sys-svc-container/templates/base.yml.j2' %} - environment: + environment: # nocheck: compose-environment-from-env-file clamav daemon-only key; this role sets no docker_compose_env, so a single templates/env.j2 would also be the env_file of the stalwart and webmail containers CLAMAV_NO_MILTERD: "false" {{ lookup('container_volumes', service_name) | indent(4) }} {{ lookup('container_networks') | indent(4) }} diff --git a/roles/web-app-stalwart/templates/test.env.j2 b/roles/web-app-stalwart/templates/test.env.j2 index e74416f36a..74598ac97b 100644 --- a/roles/web-app-stalwart/templates/test.env.j2 +++ b/roles/web-app-stalwart/templates/test.env.j2 @@ -16,4 +16,4 @@ MIGRATION_SCRIPT={{ lookup('path_absolute', 'roles', application_id, 'files/pyth PYTHON_BIN={{ (lookup('env', 'PYTHON') or '/opt/venvs/infinito/bin/python') | quote }} -STALWART_MIGRATION_E2E={{ ((application_id in PRIMARY_APPS) and ('web-app-mailu' in group_names) and DEPLOYMENT_MODE == 'compose' and IS_STACK_HOST | bool) | string | lower }} +STALWART_MIGRATION_E2E={{ ((application_id in PRIMARY_APPS) and ('web-app-mailu' in group_names) and IS_COMPOSE_MODE and IS_STACK_HOST | bool) | string | lower }} diff --git a/roles/web-app-weblate/templates/compose.yml.j2 b/roles/web-app-weblate/templates/compose.yml.j2 index efc83600d3..9be47aadcd 100644 --- a/roles/web-app-weblate/templates/compose.yml.j2 +++ b/roles/web-app-weblate/templates/compose.yml.j2 @@ -6,6 +6,7 @@ {{ lookup('compose_only', 'container_name', WEBLATE_CONTAINER) }} {{ lookup('container_ports', ['weblate', 'http', DOCKER_BIND_HOST]) | indent(4) }} {{ lookup('container_volumes', service_name) | indent(4) }} + {{ lookup('container_extra_hosts') | indent(4) }} {{ lookup('container_networks') | indent(4) }} {{ lookup('container_depends_on', application_id) | indent(4) }} {{ lookup('container_healthcheck', service_name) | indent(4) }} diff --git a/roles/web-svc-api/meta/services.yml b/roles/web-svc-api/meta/services.yml index 0f11dfa453..c6a60a87af 100644 --- a/roles/web-svc-api/meta/services.yml +++ b/roles/web-svc-api/meta/services.yml @@ -52,7 +52,7 @@ api: internal: http: 8000 local: - http: 8094 + http: 8098 healthcheck: flavor: http_status lifecycle: alpha diff --git a/tests/unit/python/cli/meta/domains/test_main.py b/tests/unit/python/cli/meta/domains/test_main.py index f69013f19c..2a2057d2b9 100644 --- a/tests/unit/python/cli/meta/domains/test_main.py +++ b/tests/unit/python/cli/meta/domains/test_main.py @@ -8,8 +8,11 @@ from unittest.mock import patch import cli.meta.domains.__main__ as mod from utils.cache.yaml import dump_yaml_str +from utils.domains.default_primary import default_domain_primary from utils.roles.mapping import ROLE_FILE_META_DOMAINS, ROLE_FILE_VARS_MAIN +DOMAIN = default_domain_primary() + class TestCliMetaApplicationsDomains(TestCase): def write_role( @@ -48,7 +51,7 @@ class TestCliMetaApplicationsDomains(TestCase): ) self.assertEqual(mod.parse_args([]).domain_primary, "explicit.env") with patch.dict(mod.os.environ, {}, clear=True): - self.assertEqual(mod.parse_args([]).domain_primary, "infinito.test") + self.assertEqual(mod.parse_args([]).domain_primary, DOMAIN) def test_cli_supports_alias_and_www_flags(self) -> None: with tempfile.TemporaryDirectory() as tmp: @@ -70,7 +73,7 @@ class TestCliMetaApplicationsDomains(TestCase): code, out, err = self._run( [ "--domain-primary", - "infinito.test", + DOMAIN, "--alias", "--www", ] @@ -81,12 +84,12 @@ class TestCliMetaApplicationsDomains(TestCase): self.assertEqual( out.strip().splitlines(), [ - "alias.infinito.test", - "dashboard.infinito.test", - "test.infinito.test", - "www.alias.infinito.test", - "www.dashboard.infinito.test", - "www.test.infinito.test", + f"alias.{DOMAIN}", + f"dashboard.{DOMAIN}", + f"test.{DOMAIN}", + f"www.alias.{DOMAIN}", + f"www.dashboard.{DOMAIN}", + f"www.test.{DOMAIN}", ], ) diff --git a/tests/unit/python/plugins/lookup/test_database.py b/tests/unit/python/plugins/lookup/test_database.py index a5193c143c..95aee7ccc6 100644 --- a/tests/unit/python/plugins/lookup/test_database.py +++ b/tests/unit/python/plugins/lookup/test_database.py @@ -231,8 +231,8 @@ class DatabaseLookupTests(unittest.TestCase): with patch.object( self.db_lookup_mod, - "get_entity_name", - side_effect=self._fake_get_entity_name, + "entity_name", + side_effect=self._fake_entity_name, ): out = lookup.run(["web-app-foo"], variables=vars_)[0] @@ -409,8 +409,8 @@ class DatabaseLookupTests(unittest.TestCase): with patch.object( self.db_lookup_mod, - "get_entity_name", - side_effect=self._fake_get_entity_name, + "entity_name", + side_effect=self._fake_entity_name, ): out = lookup.run(["web-app-foo"], variables=vars_)[0]