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.
New in version 0.10.4.
Check that the given service is available taking into account template units.
CLI Example:
salt '*' service.available sshd
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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
Disable the named service to not start when the system boots
Set to True
to start the service using --no-block
.
New in version 2017.7.0.
CLI Example:
salt '*' service.disable <service name>
Return if the named service is disabled from starting on boot
CLI Example:
salt '*' service.disabled <service 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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
Enable the named service to start when the system boots
Set to True
to start the service using --no-block
.
New in version 2017.7.0.
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.
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.
CLI Example:
salt '*' service.enable <service name>
Return if the named service is enabled to start on boot
CLI Example:
salt '*' service.enabled <service name>
New in version 2014.7.0.
Return a list of all files specified as ExecStart
for all services.
CLI Example:
salt '*' service.execs
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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
New in version 0.12.0.
Force-reload the specified service with systemd
Set to True
to start the service using --no-block
.
New in version 2017.7.0.
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.
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>
Return a list of all available services
CLI Example:
salt '*' service.get_all
Return a list of all disabled services
CLI Example:
salt '*' service.get_disabled
Return a list of all enabled services
CLI Example:
salt '*' service.get_enabled
Return a list of all running services, so far as systemd is concerned
CLI Example:
salt '*' service.get_running
New in version 2015.8.5.
Return a list of all static services
CLI Example:
salt '*' service.get_static
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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
Mask the specified service with systemd
Set to True
to mask this service only until the next reboot
New in version 2015.8.5.
CLI Example:
salt '*' service.mask foo salt '*' service.mask foo runtime=True
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, then False
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. If runtime
is False
, this function will return True
if an indefinite mask is set for the named service (otherwise False
will be returned). If runtime
is False
, this function will return True
if a runtime mask is set, otherwise False
.
Check whether or not a service is masked
Set to True
to check for a runtime mask
New 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 to True
. Otherwise, it will check for an indefinite mask.
CLI Examples:
salt '*' service.masked foo salt '*' service.masked foo runtime=True
New in version 2014.1.0.
The inverse of service.available
. Returns True
if the specified service is not available, otherwise returns False
.
CLI Example:
salt '*' service.missing sshd
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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
Reload the specified service with systemd
Set to True
to reload the service using --no-block
.
New in version 2017.7.0.
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.
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>
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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
Restart the specified service with systemd
Set to True
to start the service using --no-block
.
New in version 2017.7.0.
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.
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>
New in version 2014.7.0.
Show properties of one or more units/jobs or the manager
CLI Example:
salt '*' service.show <service 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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
Start the specified service with systemd
Set to True
to start the service using --no-block
.
New in version 2017.7.0.
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.
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>
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]
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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
Stop the specified service with systemd
Set to True
to start the service using --no-block
.
New in version 2017.7.0.
CLI Example:
salt '*' service.stop <service name>
New in version 0.15.0.
Reloads systemctl, an action needed whenever unit files are updated.
CLI Example:
salt '*' 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 the salt-minion
service is restarted while a service is being modified. If desired, usage of systemd-run(1) can be suppressed by setting a config option
called systemd.scope
, with a value of False
(no quotes).
Unmask the specified service with systemd
Set to True
to unmask this service only until the next reboot
New 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 to True
, and otherwise removes an indefinite mask.
CLI Example:
salt '*' service.unmask foo salt '*' service.unmask foo runtime=True
© 2019 SaltStack.
Licensed under the Apache License, Version 2.0.
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.systemd_service.html