From 2029acc5a9f511876c7d5dd83796df1b529e6af2 Mon Sep 17 00:00:00 2001 From: cliffmccarthy <16453869+cliffmccarthy@users.noreply.github.com> Date: Thu, 11 Sep 2025 07:21:41 -0500 Subject: [PATCH] refactor: Add MtastsDeployer - This splits the existing _uninstall_mta_sts_daemon() routine into methods for the configure and activate stages. --- cmdeploy/src/cmdeploy/__init__.py | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/cmdeploy/src/cmdeploy/__init__.py b/cmdeploy/src/cmdeploy/__init__.py index 359b7ba6..e9377abe 100644 --- a/cmdeploy/src/cmdeploy/__init__.py +++ b/cmdeploy/src/cmdeploy/__init__.py @@ -329,21 +329,21 @@ class UnboundDeployer(Deployer): ) -def _uninstall_mta_sts_daemon() -> None: - # Remove configuration. - files.file("/etc/mta-sts-daemon.yml", present=False) +class MtastsDeployer(Deployer): + def configure_impl(self): + # Remove configuration. + files.file("/etc/mta-sts-daemon.yml", present=False) + files.directory("/usr/local/lib/postfix-mta-sts-resolver", present=False) + files.file("/etc/systemd/system/mta-sts-daemon.service", present=False) - files.directory("/usr/local/lib/postfix-mta-sts-resolver", present=False) - - files.file("/etc/systemd/system/mta-sts-daemon.service", present=False) - - systemd.service( - name="Stop MTA-STS daemon", - service="mta-sts-daemon.service", - daemon_reload=True, - running=False, - enabled=False, - ) + def activate_impl(self): + systemd.service( + name="Stop MTA-STS daemon", + service="mta-sts-daemon.service", + daemon_reload=True, + running=False, + enabled=False, + ) def _configure_postfix(config: Config, debug: bool = False) -> bool: @@ -933,6 +933,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None: # Deploy acmetool to have TLS certificates. acmetool_deployer = AcmetoolDeployer(email=config.acme_email, domains=tls_domains) + mtasts_deployer = MtastsDeployer() opendkim_deployer = OpendkimDeployer(mail_domain=mail_domain) # Dovecot should be started before Postfix @@ -949,6 +950,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None: unbound_deployer, iroh_deployer, acmetool_deployer, + mtasts_deployer, opendkim_deployer, dovecot_deployer, postfix_deployer, @@ -1044,6 +1046,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None: packages="acl", ) + mtasts_deployer.install() opendkim_deployer.install() postfix_deployer.install() dovecot_deployer.install() @@ -1072,7 +1075,8 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None: dovecot_deployer.configure() postfix_deployer.configure() nginx_deployer.configure() - _uninstall_mta_sts_daemon() + mtasts_deployer.configure() + mtasts_deployer.activate() _remove_rspamd() opendkim_deployer.configure()