Repository navigation
feat(plugins/modules): add systemd_credential - #521
Merged
Merged
Conversation
NavidSassan
force-pushed
the
feat/systemd-credential
branch
from
October 28, 2026 10:40
1d398ea to
0c8c658
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
linuxfabrik.lfops.systemd_credential, a module that stores a secret as a systemd credential, as groundwork for keeping secrets that LFOps deploys out of plain configuration files. No role uses it yet;mariadb_serverwill be the first consumer in a follow-up.systemd-credsinto/etc/credstore.encrypted/<name>, whereLoadCredentialEncrypted=<name>finds it without a path (systemd NEWS 251).systemd-creds): plain file in/etc/credstore/<name>. Consumers read${CREDENTIALS_DIRECTORY:-/etc/credstore}/<name>and work with both.systemctl show --property=Version), not the installed client.systemd-creds encryptproduces a different file on every call, so the module decrypts the existing credential on the host and compares it in memory. It re-encrypts only on a difference or when decryption fails (lost host key, VM restored without/var/lib/systemd).community.general.systemd_creds_encrypt/_decryptwere not used: they need community.general >= 10.2.0 (LFOps pins < 9.0.0 for Python 3.6 on RHEL 8), and they are stateless, so a role would round-trip the plaintext to the controller and need four tasks per secret.Security (reviewed by a separate read of the code, all findings fixed):
systemd-credson stdin, never into argv; the module never returns it (contentisno_log). No occurrence in-vvvoutput.root:root 0700, credentials toroot:root 0600, also when the content already matches. A symlink or non-directory in place of the store fails the module; a symlink, FIFO or other non-regular file in place of the credential is replaced, not followed.systemd-creds' own temp file with mode0666 & ~umask;os.rename()instead ofatomic_move(), which gives new files0666 & ~umask.[A-Za-z0-9_.-], no leading dot, full match (no trailing newline). Empty content and non-root runs are rejected.Verified:
py36-target) and 3.12 / ansible-core 2.18;test_plugin_docspasses.LoadCredentialEncrypted=), Ubuntu 22.04 (249, plain): create, idempotence, check mode, content change, modes, lost host key (re-encrypts, then idempotent), plain-to-encrypted migration, absent, invalid name.