Services are defined as system daemons typically started with system init or
rc scripts. The service state uses whichever service module that is loaded on
the minion with the virtualname of
service. Services can be defined as
running or dead.
If you need to know if your init system is supported, see the list of supported
service modules for your desired init system
(systemd, sysvinit, launchctl, etc.).
Note that Salt's service execution module, and therefore this service state, uses OS grains to ascertain which service module should be loaded and used to execute service functions. As existing distributions change init systems or new distributions are created, OS detection can sometimes be incomplete. If your service states are running into trouble with init system detection, please see the Overriding Virtual Module Providers section of Salt's module documentation to work around possible errors.
The current status of a service is determined by the return code of the init/rc script status command. A status return code of 0 it is considered running. Any other return code is considered dead.
httpd: service.running: 
The service can also be set to be started at runtime via the enable option:
openvpn: service.running: - enable: True
By default if a service is triggered to refresh due to a watch statement the service is by default restarted. If the desired behavior is to reload the service, then set the reload value to True:
redis: service.running: - enable: True - reload: True - watch: - pkg: redis
More details regarding
watch can be found in the
dead(name, enable=None, sig=None, **kwargs)¶
Ensure that the named service is dead by stopping the service if it is running
Truesets the service to be enabled,
Falsesets the named service to be disabled. The default is
None, which does not enable or disable anything.
Ensure that the service is disabled on boot, only use this state if you don't want to manage the running process, remember that if you want to disable a service to use the enable: False option for the running or dead function.
Ensure that the service is enabled on boot, only use this state if you don't want to manage the running process, remember that if you want to enable a running service to use the enable: True option for the running or dead function.
mod_watch(name, sfun=None, sig=None, reload=False, full_restart=False, init_delay=None, force=False, **kwargs)¶
The service watcher, called to invoke the watch command.
running(name, enable=None, sig=None, init_delay=None, **kwargs)¶
Ensure that the service is running
watchcan be used with service.running to restart a service when
watchcan be found in the Requisites documentation.