sysctl
The sysctl.* family of state modules.
| Module | Summary |
|---|---|
sysctl.present | Ensure a kernel parameter is set to a value at runtime and, by default, persisted. |
All states also accept the full set of requisite parameters and Salt-parity state attributes — see Dependencies & Requisites.
sysctl.present
Ensure a kernel parameter is set to a value at runtime and, by default, persisted.
Source: pkg/state/modules/sysctl/sysctl_present.go
sysctl.present ensures a kernel parameter (name, defaulting to the state ID) is set to the desired value at runtime and, with persist (the default), that the same value is recorded in the Zester sysctl drop-in (/etc/sysctl.d/99-zester.conf) so it survives a reboot. value is required. With persist enabled a runtime-only match — for example a manual sysctl -w — counts as drift, because the value would not survive a reboot.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | No | State ID | kernel parameter name (e.g. net.ipv4.ip_forward); defaults to the state ID |
value | string | Yes | (none) | desired parameter value; required |
persist | bool | No | true | persist the value in a sysctl drop-in so it survives a reboot; defaults to true; a boolean that also accepts the integers 1 (true) and 0 (false) |
Effects
Check
Reads the current runtime value (via sysctl -n) and reports a change when it differs from value. With persist (the default) it ALSO reads the Zester sysctl drop-in (/etc/sysctl.d/99-zester.conf) and reports a change when the key is absent from it or persisted with a different value — so a runtime-only match is drift. A non-not-exist read error on the drop-in fails the phase rather than being treated as "no entry".
Apply
Re-reads the runtime value and, with persist, the drop-in (a self-contained flow: a watch-forced Apply bypasses Check). It sets the runtime value (via sysctl -w key=value) only when it differs and writes the drop-in entry (/etc/sysctl.d/99-zester.conf) only when it is missing or wrong — each facet is memoized for revert independently. A fully converged key is a clean no-op. Reports the key, value, previous runtime value, and persist flag in its details.
Revert
Undoes only the facets this run's Apply actually changed. A runtime value Apply set is restored to its pre-Apply value; a drop-in entry Apply changed is restored to its prior value (or removed outright when Apply introduced it) — never re-persisting the old RUNTIME value. A fresh instance (a standalone revert) recorded nothing and is an explicit clean no-op; it never writes the zero value or invents a persist entry.
Examples
Enable IP forwarding persistently
The parameter name defaults to the state ID; persist (default true) writes the drop-in entry.
net.ipv4.ip_forward:
sysctl.present:
- value: "1"Tune swappiness at runtime only
persist: false sets the runtime value without recording a drop-in entry.
vm.swappiness:
sysctl.present:
- value: "10"
- persist: falseSet a kernel parameter ad hoc
The bare positional argument is the parameter name; value is a key=value.
zester '*' sysctl.present net.ipv4.ip_forward value=1