Mechanisms reference

Updated 2026-06-21

Document version: 1.1 · Last updated: 2026-06-21

A mechanism is the named action a rule's remediation runs to change a host, such as sysctl_set, service_enabled, or file_content. You set it in a rule's remediation block. Each mechanism is backed by a handler in Kensa that knows how to apply the change and, for most mechanisms, how to undo it.

Kensa runs every change as a transaction: capture the prior state, apply the change, validate it, then commit or roll back. Two handler roles matter here:

  • A capture handler records the host's exact prior state before the change.
  • A rollback handler restores that prior state if the transaction fails.

A mechanism that has both is capturable—Kensa can reverse it. A mechanism without them is non-capturable: Kensa applies and audits the change but can't roll it back, so you mark its rule transactional: false.

This page lists every shipped mechanism, where it runs, and what reversal you get. For the guarantee itself, see Rollback and history; for the rule fields, see Rule authoring.

Operating system support

Each mechanism depends on a tool or kernel feature that must be present on the host. Kensa probes for it at runtime and skips a rule whose platform or capability the host does not meet, so a mechanism never runs where its backing tool is missing. The Runs on column below names where each mechanism's backing tool exists:

  • Any Linux—kernel or core-filesystem features present on every supported distribution.
  • RHEL 8–10—the tool ships with Red Hat Enterprise Linux 8, 9, and 10 (and compatible rebuilds and Fedora).
  • Debian, Ubuntu—the tool is apt-family.
  • A named subsystem (systemd, SELinux, GRUB, GNOME)—the host must run it.

Kensa is tested on RHEL 8, 9, and 10 and on Ubuntu. The shipped rule corpus currently targets RHEL; running it against Ubuntu skips the RHEL-only rules.

Reversal levels

LevelWhat it means
AtomicThe change lands completely or not at all, and rollback restores the prior state byte-for-byte.
ReversibleRollback restores the captured prior state and verifies it. A runtime aspect may need a restart or reboot; the limit is noted, and rollback reports a partial restore when it applies.
Best-effortRollback restores the prior state through the host's own tool (dnf, apt, augenrules). It depends on that tool and on the host's policy.
StagedThe change is pending until the next reboot. A failed boot reverts automatically.
NoneKensa records the change for audit but can't roll it back. The rule is transactional: false.

Files

MechanismWhat it changesRuns onReversal
file_contentA file's content and attributesAny LinuxAtomic
file_absentRemoves a fileAny LinuxAtomic
config_setA key's value in a config fileAny LinuxAtomic
config_set_dropinA key in a drop-in config fileAny LinuxAtomic
file_permissionsA file's mode, owner, group, and SELinux contextAny LinuxAtomic
config_appendAppends a line to a config fileAny LinuxBest-effort

Services

MechanismWhat it changesRuns onReversal
service_enabledEnables and starts a systemd unitsystemd (RHEL 8–10, Ubuntu)Reversible
service_disabledDisables and stops a systemd unitsystemd (RHEL 8–10, Ubuntu)Reversible
service_maskedMasks and stops a systemd unitsystemd (RHEL 8–10, Ubuntu)Reversible

Kernel runtime and persistence

MechanismWhat it changesRuns onReversal
sysctl_setA kernel parameter (runtime and drop-in)Any LinuxReversible
mount_option_setA mount option in fstab, then remountsAny LinuxReversible. Rollback restores the fstab line, remounts, and verifies the live options match; a mismatch is reported as a partial restore.
selinux_boolean_setA persistent SELinux booleanSELinux (RHEL 8–10)Reversible
kernel_module_disableBlacklists a kernel moduleAny LinuxReversible. If the module was loaded, rollback re-loads it and verifies; a module that can't re-load (in use, or boot-time only) is reported as a partial restore needing a reboot.
audit_rule_setLoads an audit rule and persists itRHEL 8–10; Ubuntu with auditdBest-effort. Rollback restores the rule file and reconciles the live rules; on an immutable audit config the live ruleset is locked until reboot, which rollback reports as a partial restore.

Packages

MechanismWhat it changesRuns onReversal
package_presentInstalls a package with dnfRHEL 8–10Best-effort. Rollback removes the package, which removes its dependents.
package_absentRemoves a package with dnfRHEL 8–10Best-effort. Rollback reinstalls; the version may differ from the prior one.
apt_presentInstalls a package with aptDebian, UbuntuBest-effort. Rollback removes the package.
apt_absentRemoves a package with aptDebian, UbuntuBest-effort. Rollback reinstalls; the version may differ.

Authentication and policy

MechanismWhat it changesRuns onReversal
pam_module_configureA PAM configuration fileRHEL 8–10, UbuntuBest-effort
pam_module_argAn argument on a PAM module lineRHEL 8–10, UbuntuBest-effort
authselect_feature_enableAn authselect featureRHEL 8–10Best-effort
dconf_setA system dconf key, optionally lockedGNOME (RHEL 8–10, Ubuntu)Best-effort
crypto_policy_setThe system-wide crypto policyRHEL 8–10Reversible. Rollback restores and verifies the policy; services already running keep their startup crypto until restarted (for example systemctl restart sshd).
cron_jobA cron fileRHEL 8–10, UbuntuBest-effort

Boot parameters

MechanismWhat it changesRuns onReversal
grub_parameter_setAdds a kernel boot parameterGRUB (RHEL 8–10, Ubuntu)Staged. A trial boot promotes the change; a failed boot reverts to the prior default.
grub_parameter_removeRemoves a kernel boot parameterGRUB (RHEL 8–10, Ubuntu)Staged

Kensa never edits the saved boot default directly. It stages the change through a one-shot trial boot, so a host that fails to boot reverts on its own. Kensa does not reboot the host; the change is pending until you do.

Non-reversible

MechanismWhat it changesRuns onReversal
command_execRuns an arbitrary commandAny LinuxNone
crypto_policy_subpolicyApplies a crypto subpolicyRHEL 8–10None
manualMarks a step for a human to performAny LinuxNone

These mechanisms run but Kensa can't undo them, so their rules are transactional: false. Kensa records each one in the transaction log for audit, but it isn't covered by the rollback guarantee. Use them only when no reversible mechanism fits.

Crash recovery

For a capturable mechanism, the prior state is written to durable storage before any host change. If a Kensa process is interrupted mid-transaction, run kensa recover -H <host> to roll the host back to the captured prior state. Recovery reverses every mechanism in this page that is marked Atomic, Reversible, or Best-effort; it can't reverse a transactional: false step, because none was captured.

Edit this page on GitHub →