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:beforecovers:.- 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_nameslacks it even though the whole cluster relays through it. Resolving fromgroup_nameswould 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
groupsmapping 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_PROVIDERvalue from the inventory.deployed โ roles present cluster-wide, from
deployed_roles().roles_dir โ repository
roles/directory.
- Returns:
configuredwhen that role is deployed, otherwise the highest-priority declaring role that is;configuredwhen none is.