diff --git a/plugins/module_utils/module.py b/plugins/module_utils/module.py index aa3fe1b..d890f82 100644 --- a/plugins/module_utils/module.py +++ b/plugins/module_utils/module.py @@ -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)