mirror of
https://github.com/chatmail/relay.git
synced 2026-05-11 16:34:39 +00:00
remove indirection with "stages"
This commit is contained in:
committed by
cliffmccarthy
parent
8557abacda
commit
4a154b0a2c
@@ -1138,7 +1138,7 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
|
||||
# because it creates authentication socket
|
||||
# required by Postfix.
|
||||
DovecotDeployer(config=config, disable_mail=disable_mail),
|
||||
postfix_deployer = PostfixDeployer(config=config, disable_mail=disable_mail),
|
||||
PostfixDeployer(config=config, disable_mail=disable_mail),
|
||||
FcgiwrapDeployer(),
|
||||
NginxDeployer(config=config),
|
||||
RspamdDeployer(),
|
||||
@@ -1150,12 +1150,6 @@ def deploy_chatmail(config_path: Path, disable_mail: bool) -> None:
|
||||
# Create all groups before users, because some users reference groups
|
||||
# from other classes.
|
||||
#
|
||||
for deployer in all_deployers:
|
||||
deployer.create_groups()
|
||||
|
||||
for deployer in all_deployers:
|
||||
deployer.create_users()
|
||||
|
||||
for deployer in all_deployers:
|
||||
deployer.install()
|
||||
|
||||
|
||||
@@ -5,14 +5,8 @@ from pyinfra.operations import server
|
||||
|
||||
class Deployer:
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
|
||||
default_stages = "install,configure,activate"
|
||||
stages = os.getenv("CMDEPLOY_STAGES", default_stages).split(",")
|
||||
|
||||
self.run_install = "install" in stages
|
||||
self.run_configure = "configure" in stages
|
||||
self.run_activate = "activate" in stages
|
||||
self.stages = os.getenv("CMDEPLOY_STAGES", default_stages).split(",")
|
||||
self.need_restart = False
|
||||
|
||||
#
|
||||
@@ -25,10 +19,11 @@ class Deployer:
|
||||
def required_users():
|
||||
return []
|
||||
|
||||
def create_groups(self):
|
||||
if not self.run_install:
|
||||
def install(self):
|
||||
if "install" not in self.stages:
|
||||
return
|
||||
|
||||
# create groups
|
||||
for user, group, groups in self.required_users():
|
||||
if group is not None:
|
||||
server.group(
|
||||
@@ -40,10 +35,7 @@ class Deployer:
|
||||
name="Create {} group".format(group2), group=group2, system=True
|
||||
)
|
||||
|
||||
def create_users(self):
|
||||
if not self.run_install:
|
||||
return
|
||||
|
||||
# create users
|
||||
for user, group, groups in self.required_users():
|
||||
server.user(
|
||||
name="Create {} user".format(user),
|
||||
@@ -53,9 +45,7 @@ class Deployer:
|
||||
system=True,
|
||||
)
|
||||
|
||||
def install(self):
|
||||
if self.run_install:
|
||||
self.need_restart |= bool(self.install_impl())
|
||||
self.need_restart |= bool(self.install_impl())
|
||||
|
||||
#
|
||||
# If a subclass overrides this with a method that returns a true
|
||||
@@ -66,14 +56,14 @@ class Deployer:
|
||||
pass
|
||||
|
||||
def configure(self):
|
||||
if self.run_configure:
|
||||
if "configure" in self.stages:
|
||||
self.configure_impl()
|
||||
|
||||
def configure_impl(self):
|
||||
pass
|
||||
|
||||
def activate(self):
|
||||
if self.run_activate:
|
||||
if "activate" in self.stages:
|
||||
self.activate_impl()
|
||||
|
||||
def activate_impl(self):
|
||||
|
||||
Reference in New Issue
Block a user