From 15235a718d7fb08de65ae3b41d88f79e0a8b047b Mon Sep 17 00:00:00 2001 From: David Wittman Date: Wed, 25 Mar 2015 17:21:37 -0500 Subject: [PATCH] Fix bug with upstart detection Upstart scripts are being incorrectly identified as SysV init scripts due to a logic error in the `service` module. Because upstart uses multiple commands (`/sbin/start`, `/sbin/stop`, etc.) for managing service state, the codepath for upstart sets `self.svc_cmd` to an empty string on line 451. Empty strings are considered a non-truthy value in Python, so conditionals which are checking the state of `self.svc_cmd` should explicitly compare it to `None` to avoid overlooking the fact that the service may be controlled by an upstart script. --- lib/ansible/modules/system/service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/modules/system/service.py b/lib/ansible/modules/system/service.py index a9aca1b9392..ed8a413d3b4 100644 --- a/lib/ansible/modules/system/service.py +++ b/lib/ansible/modules/system/service.py @@ -472,7 +472,7 @@ class LinuxService(Service): self.module.fail_json(msg="no service or tool found for: %s" % self.name) # If no service control tool selected yet, try to see if 'service' is available - if not self.svc_cmd and location.get('service', False): + if self.svc_cmd is None and location.get('service', False): self.svc_cmd = location['service'] # couldn't find anything yet