Krikri::PluginHelpers::AuthorizedKeysFile
AuthorizedKeysFile - pure logic for ensuring a public key line is present/absent in an OpenSSH authorized_keys-style file, entirely without I/O so it's unit-testable with plain strings.
Constants
The Ansible module's own VALID_SSH2_KEY_TYPES (ansible.posix authorized_key's parsekey): a line is a key line iff one of its whitespace-separated tokens is exactly one of these.
Class methods
Ensures key_line's signature is present (or absent) in text.
Returns {new_text, changed}.
Multi-key form mirroring the Ansible module's enforce_state: each new
key is matched against the file by its blob (the Ansible module's
parsekeys dict is keyed on the blob alone), and "already present"
means the whole parsed key matches - blob, type, OPTIONS DICT, and
comment. key_options are part of that comparison in the real
module (its parsed_new_key[:4] != existing_keys[blob][:4] check),
so adding key_options: to an existing bare key is a real change:
the old line is deleted and the options-prefixed line re-serialized
(moved to the end of the file, like the Ansible module's
delete-then-reinsert). On any write the whole file is
re-serialized from its parsed keys, exactly like the Ansible module's
serialize() pass. With exclusive (state present only), every
existing key whose blob isn't among the new keys is deleted - the
Ansible module's "remove all other keys to honor exclusive".