service¶
Service management via OpenRC.
This module registers under Salt’s service virtual name and is loaded
automatically on minions where OpenRC manages services (Alpine, Gentoo,
Artix, and other OpenRC-based distributions). Existing states such as
service.running and service.dead work without any changes to your
state files.
Important
If Salt is not using this module on an OpenRC minion (or you see an error such as ‘service.start’ is not available), see here.
Runlevels¶
OpenRC organises services into named runlevels rather than systemd targets. The two runlevels relevant to most service management work are:
defaultServices that should start when the system reaches a normal running state. This is the runlevel used by
enable()anddisable()when norunlevelargument is supplied.bootServices that must start earlier in the boot sequence, such as
networking,syslog, andhostname. To manage a service in this runlevel, passrunlevel=bootexplicitly.
Other runlevels (sysinit, shutdown, nonetwork) exist but are
rarely targeted directly by Salt states.
- saltext.openrc.modules.openrc.__virtual__()[source]¶
Only load on systems where OpenRC is present.
OpenRC is detected by the presence of the
rc-servicecommand rather than by matching a specificos_family, so the module works on any OpenRC-based distribution (Alpine, Gentoo, Artix, Devuan with OpenRC, and so on).Note
rc-servicebeing onPATHmeans the OpenRC tooling is installed, which holds on every OpenRC-based system but does not by itself prove OpenRC is managing services here (for example, a host where theopenrcpackage was installed but never actually used). To guard against that, additionally require the OpenRC runtime directory:os.path.isdir("/run/openrc")
OpenRC creates it when it brings up its runlevels, so it reliably signals OpenRC is in use regardless of what runs as PID 1 – on Alpine that is BusyBox init with OpenRC layered on top; on Gentoo it is OpenRC itself.
- saltext.openrc.modules.openrc.start(name, **_)[source]¶
Start the named service.
CLI Example:
salt '*' service.start <service name>
- saltext.openrc.modules.openrc.stop(name, **_)[source]¶
Stop the named service.
CLI Example:
salt '*' service.stop <service name>
- saltext.openrc.modules.openrc.zap(name, **_)[source]¶
Manually reset the named service to a stopped state.
CLI Example:
salt '*' service.zap <service name>
- saltext.openrc.modules.openrc.restart(name, **_)[source]¶
Restart the named service.
CLI Example:
salt '*' service.restart <service name>
- saltext.openrc.modules.openrc.reload_(name, **_)[source]¶
Send a reload signal to the named service. Not all services support reload; consult the service’s init script to confirm.
CLI Example:
salt '*' service.reload <service name>
- saltext.openrc.modules.openrc.status(name, sig=None, **_)[source]¶
Return True if the named service is running, False otherwise.
The sig parameter is accepted for interface compatibility with Salt’s generic service state but is not used; rc-service status is authoritative.
CLI Example:
salt '*' service.status <service name>
- saltext.openrc.modules.openrc.enabled(name, runlevel=None, **_)[source]¶
Return True if the named service is enabled in the given runlevel.
- runlevel
The runlevel to check. Defaults to ‘default’.
CLI Example:
salt '*' service.enabled <service name> salt '*' service.enabled <service name> runlevel=boot
- saltext.openrc.modules.openrc.disabled(name, **kwargs)[source]¶
Return True if the named service is disabled in the default runlevel.
CLI Example:
salt '*' service.disabled <service name>
- saltext.openrc.modules.openrc.enable(name, runlevel=None, **_)[source]¶
Enable the named service in the given runlevel so it starts at boot.
- runlevel
The runlevel to add the service to. Defaults to ‘default’.
CLI Example:
salt '*' service.enable <service name> salt '*' service.enable <service name> runlevel=boot
- saltext.openrc.modules.openrc.disable(name, runlevel=None, **_)[source]¶
Disable the named service in the given runlevel.
- runlevel
The runlevel to remove the service from. Defaults to ‘default’.
CLI Example:
salt '*' service.disable <service name> salt '*' service.disable <service name> runlevel=boot
- saltext.openrc.modules.openrc.available(name, **_)[source]¶
Return True if the named service exists on the system.
CLI Example:
salt '*' service.available <service name>
- saltext.openrc.modules.openrc.missing(name, **_)[source]¶
Return True if the named service is not available on the system.
CLI Example:
salt '*' service.missing <service name>
- saltext.openrc.modules.openrc.get_all(**_)[source]¶
Return a sorted list of all services known to rc-service.
CLI Example:
salt '*' service.get_all