summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <brian.coca+git@gmail.com>2015-09-02 17:09:53 -0400
committerBrian Coca <brian.coca+git@gmail.com>2015-09-02 17:11:30 -0400
commite278f285aa6f61e45416be28b1e689b4d7607196 (patch)
tree90836265cf888e962dad9d8a4e5b1be8bae2211b
parent6df6e5977e7d8cd6720bc979d575bd297721419d (diff)
downloadansible-modules-core-e278f285aa6f61e45416be28b1e689b4d7607196.tar.gz
partially reverted previous change to deal with systemctl show status not returning errors on missing service
Now it looks for not-found key instead of running status which does return error codes when service is present but in diff states. fixes #12216
-rw-r--r--system/service.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/system/service.py b/system/service.py
index 70ff8351..4255ecb8 100644
--- a/system/service.py
+++ b/system/service.py
@@ -522,13 +522,12 @@ class LinuxService(Service):
def get_systemd_status_dict(self):
# Check status first as show will not fail if service does not exist
- (rc, out, err) = self.execute_command("%s status '%s'" % (self.enable_cmd, self.__systemd_unit,))
- if rc != 0:
- self.module.fail_json(msg='failure %d running systemctl status for %r: %s' % (rc, self.__systemd_unit, err))
-
(rc, out, err) = self.execute_command("%s show '%s'" % (self.enable_cmd, self.__systemd_unit,))
if rc != 0:
self.module.fail_json(msg='failure %d running systemctl show for %r: %s' % (rc, self.__systemd_unit, err))
+ elif 'LoadState=not-found' in out:
+ self.module.fail_json(msg='systemd could not find the requested service "%r": %s' % (self.__systemd_unit, err))
+
key = None
value_buffer = []
status_dict = {}