utils.mail packageยถ

Submodulesยถ

utils.mail.provider moduleยถ

Resolve which role is the active mail provider for a deploy.

MAIL_PROVIDER is the operatorโ€™s config flag and always wins while the role it names is part of the deploy. It is a static inventory value, though, so a round that deploys only the alternative provider would otherwise resolve to a role that is not there: the provider binds no public mail ports, skips sys-ctl-mtn-cert-deploy, and every consumer resolves its SMTP host against a server that was never deployed.

Falling back to whichever declaring role IS deployed fixes that, and ordering the fallback provides: before covers: keeps it single-valued โ€” two providers can never both consider themselves active and bind port 25.

utils.mail.provider.declaring_roles(roles_dir: Path) โ†’ list[str]ยถ

Roles that declare the mail service, provides: before covers:.

Parameters:

roles_dir โ€“ repository roles/ directory.

Returns:

Role ids in fallback priority order, without duplicates.

utils.mail.provider.deployed_roles(groups: dict[str, Any] | None) โ†’ list[str]ยถ

Roles with at least one host anywhere in the inventory.

Cluster-wide, never per-host: in swarm the provider is manager-pinned, so a workerโ€™s group_names lacks it even though the whole cluster relays through it. Resolving from group_names would hand workers a different provider than the manager and render their relay config against a server they are not supposed to use.

Parameters:

groups โ€“ Ansibleโ€™s groups mapping of group name to member hosts.

Returns:

Group names that have members.

utils.mail.provider.resolve_active_provider(configured: str, deployed: list[str] | tuple[str, ...], roles_dir: Path) โ†’ strยถ

The role acting as mail provider for this deploy.

Parameters:
  • configured โ€“ the MAIL_PROVIDER value from the inventory.

  • deployed โ€“ roles present cluster-wide, from deployed_roles().

  • roles_dir โ€“ repository roles/ directory.

Returns:

configured when that role is deployed, otherwise the highest-priority declaring role that is; configured when none is.

Module contentsยถ