Skip to content

sysctl

Manages a kernel parameter (sysctl key): sets its runtime value and, by default, records it in a keystone-managed drop-in under /etc/sysctl.d/ so it survives a reboot. Idempotent: re-applying an unchanged declaration reports no change.

Category: System config

States

StateMeaning
presentThe kernel parameter (the declaration name) has the declared value; with persist: true (the default) a drop-in under /etc/sysctl.d/ also records it.

Parameters

ParameterTypeRequiredDescription
valuestringyesThe value to set. Multi-field values (e.g. "4096 16384 4194304") are whitespace-normalized; ints/bools are accepted and coerced to strings.
persistboolWrite a /etc/sysctl.d/ drop-in so the value survives reboot. Set false to change only the running value. Default: true.

Examples

Enable IPv4 forwarding (runtime + persisted)

sysctl:
  net.ipv4.ip_forward:
    state: present
    value: "1"

Set a runtime-only value

With persist: false only the running kernel value changes; no drop-in is written.

sysctl:
  net.core.somaxconn:
    state: present
    value: "1024"
    persist: false

Multi-field value (slashed key form)

Keys accept slashed notation; it is normalized to the dotted form.

sysctl:
  net/ipv4/tcp_rmem:
    state: present
    value: "4096 16384 4194304"

Notes

  • Linux only; BSD/macOS sysctl namespaces differ and are out of scope.
  • The declaration name is the kernel key, in dotted (net.ipv4.ip_forward) or slashed (net/ipv4/ip_forward) form — both normalize to the same persistence file.
  • One drop-in file per key; a single consolidated keystone drop-in is a future enhancement.
  • v0.1 sets the value directly and does not run sysctl --system, so no reload is needed this boot.