The '-s' option for restart/refresh is only supported on Oracle Solaris >= 11

Closes #20102
pull/4420/head
Jasper Lievisse Adriaanse 2017-01-23 22:06:22 +01:00 committed by Brian Coca
parent c7739be960
commit a412be32b5
1 changed files with 15 additions and 2 deletions

View File

@ -1303,6 +1303,19 @@ class SunOSService(Service):
if not self.svcadm_cmd: if not self.svcadm_cmd:
self.module.fail_json(msg='unable to find svcadm binary') 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): def get_service_status(self):
status = self.get_sunos_svcs_status() status = self.get_sunos_svcs_status()
# Only 'online' is considered properly running. Everything else is off # Only 'online' is considered properly running. Everything else is off
@ -1394,9 +1407,9 @@ class SunOSService(Service):
elif self.action == 'stop': elif self.action == 'stop':
subcmd = "disable -st" subcmd = "disable -st"
elif self.action == 'reload': elif self.action == 'reload':
subcmd = "refresh -s" subcmd = "refresh %s" % (self.svcadm_sync)
elif self.action == 'restart' and status == 'online': elif self.action == 'restart' and status == 'online':
subcmd = "restart -s" subcmd = "restart %s" % (self.svcadm_sync)
elif self.action == 'restart' and status != 'online': elif self.action == 'restart' and status != 'online':
subcmd = "enable -rst" subcmd = "enable -rst"