1
0
Fork 0

added the ability for the author of the module to decide if the module is not restartable/needs restarts

Dieser Commit ist enthalten in:
Sebastian Tobie 2023-04-26 19:01:08 +02:00
Ursprung 20bb6b1f16
Commit 3e0cb17222
1 geänderte Dateien mit 2 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -350,13 +350,14 @@ def installable(_class: Type[SystemdUnitModule]):
class SystemdReloadMixin: class SystemdReloadMixin:
module: basic.AnsibleModule module: basic.AnsibleModule
unitfile: pathlib.Path unitfile: pathlib.Path
restartable: bool = True
changed: bool changed: bool
def post(self): def post(self):
if not self.changed: if not self.changed:
return return
systemctl = self.module.get_bin_path("systemctl", required=True) systemctl = self.module.get_bin_path("systemctl", required=True)
self.module.run_command([systemctl, "daemon-reload"], check_rc=True) self.module.run_command([systemctl, "daemon-reload"], check_rc=True)
if self.unitfile.stem.endswith("@"): if self.unitfile.stem.endswith("@") or not self.restartable:
return return
(rc, _, _) = self.module.run_command([systemctl, "is-enabled", self.unitfile.name], check_rc=False) (rc, _, _) = self.module.run_command([systemctl, "is-enabled", self.unitfile.name], check_rc=False)
if rc == 0: if rc == 0: