Krikri::PluginHelpers::BlockEditor
BlockEditor - pure marker-delimited-block matching/insertion logic for the blockinfile plugin, factored out the same way LineEditor is for lineinfile so it can be unit tested without touching the filesystem.
Behavior verified empirically against real ansible-playbook (not
assumed from docs): the begin/end marker lines are matched by exact
equality (not regex), an existing block's insertion position never
moves once found (only its interior is rewritten), a fresh block is
inserted with no surrounding blank line via the exact same
insertafter/insertbefore rules lineinfile already uses (default EOF),
and an unchanged run's message is the empty string (not e.g. "Block
already present").
Class methods
Returns {new_lines, changed}. append_newline/prepend_newline mirror real Ansible's blank-line padding around the block (present state only): prepend puts a blank line between the preceding content and the block (skipped at BOF or when the preceding line is already blank), append puts one between the block and what follows it (skipped at EOF or when that line is already blank) - both no-ops on reruns, since the blank line they add satisfies them the next time.