mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Add initial upstart support for Ubuntu
This commit is contained in:
parent
632336ffbb
commit
e1bcb75a71
@ -26,6 +26,7 @@ def __virtual__():
|
||||
'Scientific',
|
||||
'Fedora',
|
||||
'Gentoo',
|
||||
'Ubuntu',
|
||||
'FreeBSD',
|
||||
'Windows',
|
||||
]
|
||||
|
76
salt/modules/upstart.py
Normal file
76
salt/modules/upstart.py
Normal file
@ -0,0 +1,76 @@
|
||||
'''
|
||||
Module for the management of upstart systems. The Upstart system only supports
|
||||
service starting, stopping and restarting.
|
||||
|
||||
DO NOT use this module on red hat systems, as red hat systems should use the
|
||||
rh_service module, since red hat systems support chkconfig
|
||||
'''
|
||||
|
||||
import os
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
Only work on Ubuntu
|
||||
'''
|
||||
# Disable on these platforms, specific service modules exist:
|
||||
if __grains__['os'] == 'Ubuntu':
|
||||
return 'service'
|
||||
return False
|
||||
|
||||
|
||||
def _runlevel():
|
||||
'''
|
||||
Return the current runlevel
|
||||
'''
|
||||
out = __salt__['cmd.run']('runlevel').strip()
|
||||
return out.split()[1]
|
||||
|
||||
|
||||
def start(name):
|
||||
'''
|
||||
Start the specified service
|
||||
|
||||
CLI Example::
|
||||
|
||||
salt '*' service.start <service name>
|
||||
'''
|
||||
cmd = 'service {0} start'.format(name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
|
||||
|
||||
def stop(name):
|
||||
'''
|
||||
Stop the specified service
|
||||
|
||||
CLI Example::
|
||||
|
||||
salt '*' service.stop <service name>
|
||||
'''
|
||||
cmd = 'service {0} stop'.format(name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
|
||||
|
||||
def restart(name):
|
||||
'''
|
||||
Restart the named service
|
||||
|
||||
CLI Example::
|
||||
|
||||
salt '*' service.restart <service name>
|
||||
'''
|
||||
cmd = 'service {0} restart'.format(name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
|
||||
|
||||
def status(name, sig=None):
|
||||
'''
|
||||
Return the status for a service, returns a bool whether the service is
|
||||
running.
|
||||
|
||||
CLI Example::
|
||||
|
||||
salt '*' service.status <service name>
|
||||
'''
|
||||
cmd = 'service {0} status'.format(name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
Loading…
Reference in New Issue
Block a user