mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Refactor new win_ntp module
Use built in service management functions to handle starting/restarting services.
This commit is contained in:
parent
0ce1473298
commit
2ee1dab825
@ -31,12 +31,16 @@ def set_servers(*servers):
|
||||
|
||||
salt '*' ntp.set_servers 'pool.ntp.org' 'us.pool.ntp.org'
|
||||
'''
|
||||
cmd = ('W32tm /config /syncfromflags:manual /manualpeerlist:"{0}" &&'
|
||||
'W32tm /config /reliable:yes &&'
|
||||
'W32tm /config /update &&'
|
||||
'Net stop w32time && Net start w32time'
|
||||
).format(' '.join(servers))
|
||||
ret = __salt__['cmd.run'](cmd)
|
||||
service_name = 'w32time'
|
||||
if not __salt__['service.status'](service_name):
|
||||
if not __salt__['service.start'](service_name):
|
||||
return False
|
||||
ret = __salt__['cmd.run'](
|
||||
'W32tm /config /syncfromflags:manual /manualpeerlist:"{0}" &&'
|
||||
'W32tm /config /reliable:yes && W32tm /config /update'
|
||||
.format(' '.join(servers))
|
||||
)
|
||||
__salt__['service.restart'](service_name)
|
||||
return 'command completed successfully' in ret
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user