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