From 08af5f833fb5e84e6e89a849a9d101e7558d1a47 Mon Sep 17 00:00:00 2001 From: Ingo Gottwald Date: Fri, 13 Sep 2013 22:04:37 +0200 Subject: [PATCH] Bugfix service module: Only change service state when needed --- system/service | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/system/service b/system/service index bf214bccd5f..d66a09e8e4d 100644 --- a/system/service +++ b/system/service @@ -144,6 +144,7 @@ class Service(object): self.rcconf_file = None self.rcconf_key = None self.rcconf_value = None + self.svc_change = False # select whether we dump additional debug info through syslog self.syslogging = False @@ -271,18 +272,18 @@ class Service(object): self.module.fail_json(msg="failed determining service state, possible typo of service name?") # Find out if state has changed if not self.running and self.state in ["started", "running"]: - self.changed = True + self.svc_change = True elif self.running and self.state in ["stopped","reloaded"]: - self.changed = True + self.svc_change = True elif self.state == "restarted": - self.changed = True - if self.module.check_mode and self.changed: + self.svc_change = True + if self.module.check_mode and self.svc_change: self.module.exit_json(changed=True, msg='service state changed') def modify_service_state(self): # Only do something if state will change - if self.changed: + if self.svc_change: # Control service if self.state in ['started', 'running']: self.action = "start" @@ -1123,6 +1124,8 @@ def main(): else: module.fail_json(msg=out) + if service.svc_change is True: + service.changed = True result['changed'] = service.changed if service.module.params['enabled'] is not None: result['enabled'] = service.module.params['enabled']