GuidesModules
service.dead
Ensures a service is stopped on the target system. Optionally also disables the service at boot when enable: false is set.
Source: pkg/state/modules/service.go
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | No | State ID | The service name. If omitted, the state ID is used. |
enable | bool | No | true | When set to false, also disables the service at boot during Apply. |
All states also accept the full set of requisite parameters and Salt-parity state attributes — see Dependencies & Requisites.
Check Behavior
- Calls
systemctl is-active --quiet <service>(via the injected ServiceExec). - Reports no changes needed if the service is already stopped.
- Reports
NeedsChange: trueif the service is running.
Apply Behavior
- Calls
Stopon the service. - If
enable: falseand the service is currently enabled: callsDisableand records the action (for Revert). - Returns
Changed: true.
Revert Behavior
- If Apply disabled the service: calls
Enable. - Calls
Startto restore the service to a running state. - Returns
Changed: true.
Details Returned
| Key | Description |
|---|---|
service | The service name |
manager | The service manager name (e.g., "systemd") |
Examples
Stop a service (leave boot configuration unchanged)
apache2:
service.dead: []Stop and disable a service at boot
apache2:
service.dead:
- enable: falseStop a conflicting service before starting another
apache2:
service.dead:
- enable: false
nginx:
service.running:
- enable: true
- require:
- service.dead:apache2Explicit name
disable-telnet:
service.dead:
- name: telnet
- enable: false