Files
computer-playbook/roles/sys-svc-mail
kevinveenbirkenbachandClaude Opus 5 3c72c2002a refactor(credentials)!: give applications their own administrator account
Application roles used the host administrator account.
user-administrator/tasks/00_core.yml:17 hashes its password into the OS
user, files/administrator grants that name ALL=(ALL) ALL without
NOPASSWD, and rotate.py lists it in ROTATION_EXEMPT, so the value is
password-authenticated sudo that cannot be rotated to recover. Every role
that typed it into a web form was typing the host sudo credential, and the
staged Playwright env carrying it is written mode 0644.

roles/user-administrator/meta/users.yml now declares platform_administrator
beside administrator: no host account, no rotation exemption, mailbox and
identity so it stays SSO-capable and can receive the mail applications send
to their admin. Every use moves to it, all fields and not only the
password: leaving .email behind built accounts from both identities at
once, with the host operator's address under the platform account's login
name, and an IdP matching on e-mail resolves such an account back to the
host operator.

The account is reachable by two spellings, and both are migrated:
lookup('users', 'administrator') in its two- and three-argument forms, and
the dotted lookup('config', application_id, 'users.administrator.email')
that five roles used. administrator is now referenced nowhere outside
roles/user-administrator.

Four lints hold the boundary:

  - no role outside user-administrator may use the host administrator, in
    either spelling or as a *user_key literal
  - a role that looks a user up must declare it in its own meta/users.yml,
    because required_user_policies only pins passwords for users declared
    by a role resolved into the inventory, and those are the invokable
    roles; a user declared only by a non-invokable role keeps the
    {{ 42 | strong_password }} fallback, which re-renders per evaluation
  - a role that iterates a user or passes it as a *user_key must declare it
  - the biber and mapache test personas may be read only from the
    Playwright and CLI test surfaces

Two credentials that were derived by hashing the admin password get their
own declaration, because deriving them tied an unrelated rotation to a
password change: web-app-fider jwt_secret, which signs session and e-mail
sign-in tokens, and web-app-nextcloud integration_suitecrm_client_secret,
whose two ends must be re-registered in lockstep.

web-app-keycloak separates the two admins it has: a new meta/users.yml
declares keycloak_bootstrap for the temporary account the container creates
on first start, while the permanent account is platform_administrator. Both
resolve in vars/main.yml so the lookup runs once per role.

web-app-semaphore's break-glass admin no longer shares ansible_become_password
and no longer forwards its mail to the host administrator; tasks/02_breakglass.yml
realigns the password on every deploy, so it converges on its own.

The six roles whose meta/secrets.yml declared administrator_password as its
only credential lose the file.

tests/integration/ansible/lookups/test_declared_users_resolve.py runs the
lookup through the real plugin loader and fails on a declared user that
cannot be resolved or whose username, e-mail or password renders empty. The
two declarations reading ansible_become_password resolve to an empty string
when that variable is absent, and nothing raises on it.

Existing deployments keep the admin account their application database
already holds, under the old name. Roles that re-apply the credential every
run converge; 30 roles feed it from config with no provisioning task and do
not, so those accounts need a reset. web-app-friendica additionally guards
on "'administrator' not in stdout", which the substring platform-administrator
satisfies, and web-app-n8n initialises an owner that already exists.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-08 16:28:52 +02:00
..
…

sys-svc-mail

Description

The sys-svc-mail role acts as the central mail orchestration layer in the Infinito.Nexus stack.
It wires together:

  • Stalwart as a full-featured mail server (when available),
  • msmtp as a lightweight sendmail-compatible SMTP client, and
  • an optional local SMTP relay (Postfix) for hosts without Stalwart.

For more background on the underlying protocol, see Simple Mail Transfer Protocol (SMTP) on Wikipedia.

Overview

This role provides a unified mail setup for your hosts:

  • If the host is part of the active mail provider's group (MAIL_PROVIDER), it:

    • asserts the provider endpoint was preloaded (submission token present),
    • and prepares the system to send emails through the provider using the sys-svc-mail-msmtp role.
  • If the host is not running Stalwart, it:

    • optionally configures a local SMTP relay via sys-svc-mail-smtp (Postfix on localhost:25),
    • and still configures msmtp as a sendmail-compatible client.

This makes sys-svc-mail the canonical entrypoint for “mail capabilities” on a node, abstracting away whether the actual delivery happens via Stalwart or a local relay.

Purpose

The main purpose of this role is to:

  • Provide a consistent mail-sending interface for all hosts in the Infinito.Nexus ecosystem.
  • Automatically choose between:
    • Stalwart-backed delivery (with authentication tokens), or
    • a local SMTP relay on localhost, depending on the presence of web-app-stalwart in the host’s groups.
  • Ensure that system services and applications can always send notifications (e.g. health checks, alerts, job results) without each role having to care about the underlying mail plumbing.

Features

  • 🔄 Mail-provider integration (when available)

    • Asserts the active provider's submission token was provisioned before configuring external mail.
    • Routes outbound mail through the provider via sys-svc-mail-msmtp.
  • 💡 Smart Fallback to Localhost

    • If no web-app-stalwart is present, the role can configure a local Postfix-based SMTP relay via sys-svc-mail-smtp.
    • Combined with sys-svc-mail-msmtp, this enables sending mail via localhost:25 without additional configuration in other roles.
  • 📨 msmtp Client Configuration

    • Delegates installation and configuration of msmtp to sys-svc-mail-msmtp.
    • Supports both authenticated Stalwart delivery and unauthenticated localhost-based delivery.
  • 🧩 Composable Design

    • Uses internal run_once_* flags to avoid repeated setup.
    • Cleanly integrates with the Infinito.Nexus stack and shared utilities.

Further Resources