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.
- salt.modules.systemd_service.available(name)#
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.disable(name, no_block=False, root=None, **kwargs)#
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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).Disable the named service to not start when the system boots
- no_blockFalse
Set to
Trueto disable 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.disabled(name, root=None)#
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.enable(name, no_block=False, unmask=False, unmask_runtime=False, root=None, **kwargs)#
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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).Enable the named service to start when the system boots
- no_blockFalse
Set to
Trueto enable the service using--no-block.New in version 2017.7.0.
- unmaskFalse
Set to
Trueto 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
Trueto 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.enabled(name, 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.execs(root=None)#
New in version 2014.7.0.
Return a list of all files specified as
ExecStartfor all services.- root
Enable/disable/mask unit files in the specified root directory
CLI Example:
salt '*' service.execs
- salt.modules.systemd_service.firstboot(locale=None, locale_message=None, keymap=None, timezone=None, hostname=None, machine_id=None, 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.force_reload(name, no_block=True, 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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).New in version 0.12.0.
Force-reload the specified service with systemd
- no_blockFalse
Set to
Trueto force_reload the service using--no-block.New in version 2017.7.0.
- unmaskFalse
Set to
Trueto 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
Trueto 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.get_all(root=None)#
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_disabled(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_enabled(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_running()#
Return a list of all running services, so far as systemd is concerned
CLI Example:
salt '*' service.get_running
- salt.modules.systemd_service.get_static(root=None)#
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.mask(name, runtime=False, 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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).Mask the specified service with systemd
- runtimeFalse
Set to
Trueto 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.masked(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-enabledcommand (so that a persistent mask can be distinguished from a runtime mask). If the service is not masked, thenFalsewill be returned.Changed in version 2017.7.0: This function now returns a boolean telling the user whether a mask specified by the new
runtimeargument is set. IfruntimeisFalse, this function will returnTrueif an indefinite mask is set for the named service (otherwiseFalsewill be returned). IfruntimeisFalse, this function will returnTrueif a runtime mask is set, otherwiseFalse.Check whether or not a service is masked
- runtimeFalse
Set to
Trueto check for a runtime maskNew in version 2017.7.0: In previous versions, this function would simply return the output of
systemctl is-enabledwhen 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.missing(name)#
New in version 2014.1.0.
The inverse of
service.available. ReturnsTrueif the specified service is not available, otherwise returnsFalse.CLI Example:
salt '*' service.missing sshd
- salt.modules.systemd_service.offline()#
New in version 3004.
Check if systemd is working in offline mode, where is not possible to talk with PID 1.
CLI Example:
salt '*' service.offline
- 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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).Reload the specified service with systemd
- no_blockFalse
Set to
Trueto reload the service using--no-block.New in version 2017.7.0.
- unmaskFalse
Set to
Trueto 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
Trueto 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.restart(name, no_block=None, 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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).Restart the specified service with systemd
- no_blockFalse
Set to
Trueto restart the service using--no-block. Defaults toTruefor the salt-minion service.New in version 2017.7.0.
Changed in version 3006.15: The default value for this argument has changed if the service is the salt-minion service, where it now defaults to
Trueto prevent a deadlock with the minion waiting for the service to stop before exiting.- unmaskFalse
Set to
Trueto 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
Trueto 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.show(name, root=None)#
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.start(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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).Start the specified service with systemd
- no_blockFalse
Set to
Trueto start the service using--no-block.New in version 2017.7.0.
- unmaskFalse
Set to
Trueto 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
Trueto 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.status(name, sig=None)#
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.stop(name, no_block=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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).Stop the specified service with systemd
- no_blockFalse
Set to
Trueto stop the service using--no-block. Defaults toTruefor the salt-minion service.New in version 2017.7.0.
Changed in version 3006.15: The default value for this argument has changed if the service is the salt-minion service, where it now defaults to
Trueto prevent a deadlock with the minion waiting for the service to stop before exiting.
CLI Example:
salt '*' service.stop <service name>
- salt.modules.systemd_service.systemctl_reload()#
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.unmask_(name, runtime=False, 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-miniondaemon's control group. This is done to avoid a race condition in cases where thesalt-minionservice is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting aconfig optioncalledsystemd.scope, with a value ofFalse(no quotes).Unmask the specified service with systemd
- runtimeFalse
Set to
Trueto 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-enabledon 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