added an mixin for reloading and restarting changed services
Dieser Commit ist enthalten in:
Ursprung
e94dbec9f4
Commit
e006d94584
|
@ -345,3 +345,16 @@ def installable(_class: Type[SystemdUnitModule]):
|
|||
_class.install = install
|
||||
_class.module_spec = specs
|
||||
return _class
|
||||
|
||||
|
||||
class SystemdReloadMixin(SystemdUnitModule):
|
||||
def post(self):
|
||||
if not self.changed:
|
||||
return
|
||||
systemctl = self.module.get_bin_path("systemctl", required=True)
|
||||
self.module.run_command([systemctl, "daemon-reload"], check_rc=True)
|
||||
if self.unitfile.stem.endswith("@"):
|
||||
return
|
||||
(rc, _, _) = self.module.run_command([systemctl, "is-enabled", self.unitfile.name], check_rc=False)
|
||||
if rc == 0:
|
||||
self.module.run_command([systemctl, "restart", self.unitfile.name], check_rc=True)
|
||||
|
|
Laden…
In neuem Issue referenzieren