salt.modules.systemd_service
Provides the service module for systemd
New in version 0.10.0.
Important
If you feel that Salt should be using this module to manage services on a minion, and it is using a different module (or gives an error similar to 'service.start' is not available), see here.
Important
This is an implementation of virtual 'service' module. As such, you must call it under the name 'service' and NOT 'systemd'. You can see that also in the examples below.
-
New in version 0.10.4.
Check that the given service is available taking into account template units.
CLI Example:
salt '*' service.available sshd
salt.modules.systemd_service.available(name)
-
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).Disable the named service to not start when the system boots
- no_blockFalse
-
Set to
True
to start the service using--no-block
.New in version 2017.7.0.
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.disable <service name>
salt.modules.systemd_service.disable(name, no_block=False, root=None, **kwargs)
-
Return if the named service is disabled from starting on boot
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.disabled <service name>
salt.modules.systemd_service.disabled(name, root=None)
-
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).Enable the named service to start when the system boots
- no_blockFalse
-
Set to
True
to start the service using--no-block
.New in version 2017.7.0.
- unmaskFalse
-
Set to
True
to remove an indefinite mask before attempting to enable the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before enabling. This behavior is no longer the default.
- unmask_runtimeFalse
-
Set to
True
to remove a runtime mask before attempting to enable the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before enabling. This behavior is no longer the default.
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.enable <service name>
salt.modules.systemd_service.enable(name, no_block=False, unmask=False, unmask_runtime=False, root=None, **kwargs)
-
Return if the named service is enabled to start on boot
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.enabled <service name>
salt.modules.systemd_service.enabled(name, root=None, **kwargs)
-
New in version 2014.7.0.
Return a list of all files specified as
ExecStart
for all services.- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.execs
salt.modules.systemd_service.execs(root=None)
-
New in version 3001.
Call systemd-firstboot to configure basic settings of the system
- locale
-
Set primary locale (LANG=)
- locale_message
-
Set message locale (LC_MESSAGES=)
- keymap
-
Set keymap
- timezone
-
Set timezone
- hostname
-
Set host name
- machine_id
-
Set machine ID
- root
-
Operate on an alternative filesystem root
CLI Example:
salt '*' service.firstboot keymap=jp locale=en_US.UTF-8
salt.modules.systemd_service.firstboot(locale=None, locale_message=None, keymap=None, timezone=None, hostname=None, machine_id=None, root=None)
-
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).New in version 0.12.0.
Force-reload the specified service with systemd
- no_blockFalse
-
Set to
True
to start the service using--no-block
.New in version 2017.7.0.
- unmaskFalse
-
Set to
True
to remove an indefinite mask before attempting to force-reload the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before force-reloading. This behavior is no longer the default.
- unmask_runtimeFalse
-
Set to
True
to remove a runtime mask before attempting to force-reload the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before force-reloading. This behavior is no longer the default.
CLI Example:
salt '*' service.force_reload <service name>
salt.modules.systemd_service.force_reload(name, no_block=True, unmask=False, unmask_runtime=False)
-
Return a list of all available services
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.get_all
salt.modules.systemd_service.get_all(root=None)
-
Return a list of all disabled services
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.get_disabled
salt.modules.systemd_service.get_disabled(root=None)
-
Return a list of all enabled services
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.get_enabled
salt.modules.systemd_service.get_enabled(root=None)
-
Return a list of all running services, so far as systemd is concerned
CLI Example:
salt '*' service.get_running
salt.modules.systemd_service.get_running()
-
New in version 2015.8.5.
Return a list of all static services
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.get_static
salt.modules.systemd_service.get_static(root=None)
-
New in version 2015.5.0.
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).Mask the specified service with systemd
- runtimeFalse
-
Set to
True
to mask this service only until the next rebootNew in version 2015.8.5.
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.mask foo salt '*' service.mask foo runtime=True
salt.modules.systemd_service.mask(name, runtime=False, root=None)
-
New in version 2015.8.0.
Changed in version 2015.8.5: The return data for this function has changed. If the service is masked, the return value will now be the output of the
systemctl is-enabled
command (so that a persistent mask can be distinguished from a runtime mask). If the service is not masked, thenFalse
will be returned.Changed in version 2017.7.0: This function now returns a boolean telling the user whether a mask specified by the new
runtime
argument is set. Ifruntime
isFalse
, this function will returnTrue
if an indefinite mask is set for the named service (otherwiseFalse
will be returned). Ifruntime
isFalse
, this function will returnTrue
if a runtime mask is set, otherwiseFalse
.Check whether or not a service is masked
- runtimeFalse
-
Set to
True
to check for a runtime maskNew in version 2017.7.0: In previous versions, this function would simply return the output of
systemctl is-enabled
when the service was found to be masked. However, since it is possible to both have both indefinite and runtime masks on a service simultaneously, this function now only checks for runtime masks if this argument is set toTrue
. Otherwise, it will check for an indefinite mask. - root
-
Enable/disable/mask unit files in the specified root directory
CLI Examples:
salt '*' service.masked foo salt '*' service.masked foo runtime=True
salt.modules.systemd_service.masked(name, runtime=False, root=None)
-
New in version 2014.1.0.
The inverse of
service.available
. ReturnsTrue
if the specified service is not available, otherwise returnsFalse
.CLI Example:
salt '*' service.missing sshd
salt.modules.systemd_service.missing(name)
-
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).Reload the specified service with systemd
- no_blockFalse
-
Set to
True
to reload the service using--no-block
.New in version 2017.7.0.
- unmaskFalse
-
Set to
True
to remove an indefinite mask before attempting to reload the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before reloading. This behavior is no longer the default.
- unmask_runtimeFalse
-
Set to
True
to remove a runtime mask before attempting to reload the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before reloading. This behavior is no longer the default.
CLI Example:
salt '*' service.reload <service name>
salt.modules.systemd_service.reload_(name, no_block=False, unmask=False, unmask_runtime=False)
-
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).Restart the specified service with systemd
- no_blockFalse
-
Set to
True
to start the service using--no-block
.New in version 2017.7.0.
- unmaskFalse
-
Set to
True
to remove an indefinite mask before attempting to restart the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before restarting. This behavior is no longer the default.
- unmask_runtimeFalse
-
Set to
True
to remove a runtime mask before attempting to restart the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before restarting. This behavior is no longer the default.
CLI Example:
salt '*' service.restart <service name>
salt.modules.systemd_service.restart(name, no_block=False, unmask=False, unmask_runtime=False)
-
New in version 2014.7.0.
Show properties of one or more units/jobs or the manager
- root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.show <service name>
salt.modules.systemd_service.show(name, root=None)
-
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).Start the specified service with systemd
- no_blockFalse
-
Set to
True
to start the service using--no-block
.New in version 2017.7.0.
- unmaskFalse
-
Set to
True
to remove an indefinite mask before attempting to start the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before starting. This behavior is no longer the default.
- unmask_runtimeFalse
-
Set to
True
to remove a runtime mask before attempting to start the service.New in version 2017.7.0: In previous releases, Salt would simply unmask a service before starting. This behavior is no longer the default.
CLI Example:
salt '*' service.start <service name>
salt.modules.systemd_service.start(name, no_block=False, unmask=False, unmask_runtime=False)
-
Return the status for a service via systemd. If the name contains globbing, a dict mapping service name to True/False values is returned.
Changed in version 2018.3.0: The service name can now be a glob (e.g.
salt*
)- Parameters
- Returns
-
True if running, False otherwise dict: Maps service name to True if running, False otherwise
- Return type
CLI Example:
salt '*' service.status <service name> [service signature]
salt.modules.systemd_service.status(name, sig=None)
-
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).Stop the specified service with systemd
- no_blockFalse
-
Set to
True
to start the service using--no-block
.New in version 2017.7.0.
CLI Example:
salt '*' service.stop <service name>
salt.modules.systemd_service.stop(name, no_block=False)
-
New in version 0.15.0.
Reloads systemctl, an action needed whenever unit files are updated.
CLI Example:
salt '*' service.systemctl_reload
salt.modules.systemd_service.systemctl_reload()
-
New in version 2015.5.0.
Changed in version 2015.8.12,2016.3.3,2016.11.0: On minions running systemd>=205, systemd-run(1) is now used to isolate commands run by this function from the
salt-minion
daemon's control group. This is done to avoid a race condition in cases where thesalt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig option
calledsystemd.scope
, with a value ofFalse
(no quotes).Unmask the specified service with systemd
- runtimeFalse
-
Set to
True
to unmask this service only until the next rebootNew in version 2017.7.0: In previous versions, this function would remove whichever mask was identified by running
systemctl is-enabled
on the service. However, since it is possible to both have both indefinite and runtime masks on a service simultaneously, this function now removes a runtime mask only when this argument is set toTrue
, and otherwise removes an indefinite mask. - root
-
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.unmask foo salt '*' service.unmask foo runtime=True
salt.modules.systemd_service.unmask_(name, runtime=False, root=None)
© 2021 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltproject.io/en/latest/ref/modules/all/salt.modules.systemd_service.html