module

Krikri::PluginHelpers::KernelBlacklistFile

KernelBlacklistFile - pure line-editing logic for community.general.kernel_blacklist (see plugins/kernel_blacklist.cr): given the blacklist file's existing lines, computes what the file should look like for the requested state. Pure functions so the real module's match semantics are unit-testable without a modprobe.d directory to write to.

The real module (Blacklist in kernel_blacklist.py) matches with ^blacklist\s+<re.escape(name)>$ against each line STRIPPED, skipping lines whose stripped form starts with "#", and rewrites the file as one entry per line (each newline-terminated).

Class methods

apply(lines : Array(String) | Nil, module_name : String, state : String) : Tuple(Array(String), Bool)

Applies state to lines. Returns the (possibly new) line list and whether anything changed - including the real module's quirk that creating a previously-missing file counts as a change on its own (state=absent against a missing file still reports changed=true in real Ansible, because the file got created).

Source
blacklisted?(lines : Array(String), module_name : String) : Bool

Whether the module is blacklisted: any non-comment line whose stripped form matches the pattern exactly.

Source
pattern(module_name : String) : Regex
Source