From a412be32b58473f932947c5be602989377b34e66 Mon Sep 17 00:00:00 2001 From: Jasper Lievisse Adriaanse Date: Mon, 23 Jan 2017 22:06:22 +0100 Subject: [PATCH] The '-s' option for restart/refresh is only supported on Oracle Solaris >= 11 Closes #20102 --- lib/ansible/modules/system/service.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/system/service.py b/lib/ansible/modules/system/service.py index fd804ed739..fe7b08b30a 100644 --- a/lib/ansible/modules/system/service.py +++ b/lib/ansible/modules/system/service.py @@ -1303,6 +1303,19 @@ class SunOSService(Service): if not self.svcadm_cmd: self.module.fail_json(msg='unable to find svcadm binary') + if self.svcadm_supports_sync(): + self.svcadm_sync = '-s' + else: + self.svcadm_sync = '' + + def svcadm_supports_sync(self): + # Support for synchronous restart/refresh is only supported on + # Oracle Solaris >= 11. + for line in open('/etc/release', 'r').readlines(): + m = re.match('\s+Oracle Solaris (\d+\.\d+).*', line.rstrip()) + if m and m.groups()[0] > 10: + return True + def get_service_status(self): status = self.get_sunos_svcs_status() # Only 'online' is considered properly running. Everything else is off @@ -1394,9 +1407,9 @@ class SunOSService(Service): elif self.action == 'stop': subcmd = "disable -st" elif self.action == 'reload': - subcmd = "refresh -s" + subcmd = "refresh %s" % (self.svcadm_sync) elif self.action == 'restart' and status == 'online': - subcmd = "restart -s" + subcmd = "restart %s" % (self.svcadm_sync) elif self.action == 'restart' and status != 'online': subcmd = "enable -rst"