Skip to content

feat(roles/mariadb_server): store the dump login as a systemd credential - #522

Merged
NavidSassan merged 4 commits into
mainfrom
feat/mariadb-dump-credential
Oct 29, 2026
Merged

NavidSassan merged 4 commits into
mainfrom
feat/mariadb-dump-credential

Conversation

@NavidSassan

Copy link
Copy Markdown
Member

Depends on #521 (systemd_credential module); until that is merged, this PR also shows its commit.

First consumer of linuxfabrik.lfops.systemd_credential: the login of the dump user moves from /etc/mariadb-dump-login.cnf (plain text, since #505) to the systemd credential mariadb-dump-login.cnf.

  • systemd >= 251 (RHEL 9/10, Debian 12/13, Ubuntu 24.04/26.04): encrypted in /etc/credstore.encrypted/; mariadb-dump.service gets LoadCredentialEncrypted=mariadb-dump-login.cnf and reads $CREDENTIALS_DIRECTORY/mariadb-dump-login.cnf. The host key /var/lib/systemd/credential.secret is not in the duplicity default sources, so a backup of /etc no longer contains the password.
  • RHEL 8 (239), Ubuntu 22.04 (249): plain text in /etc/credstore/ (root, 0600); the script falls back to it via ${CREDENTIALS_DIRECTORY:-/etc/credstore}.
  • The old /etc/mariadb-dump-login.cnf and the copies backup: true left next to it (/etc/mariadb-dump-login.cnf.<pid>.<date>~, each with the plain password) are removed.
  • The oneshot service loads the credential on every start, so no restart handler is needed.
  • /usr/local/bin/mariadb-dump started directly aborts with a hint to use systemctl start mariadb-dump.service.
  • README: where the login lives per platform, what stays readable (root; plain text on RHEL 8 / Ubuntu 22.04), the TPM2/Secure Boot caveat.

Verified with Molecule mariadb_server on Rocky 8, Rocky 9, Debian 13 and Ubuntu 22.04: converge, verify, idempotence, verify. The scenario's dump password carries a marker, and verify.yml greps all of /etc for it: no match on systemd >= 251, only /etc/credstore/mariadb-dump-login.cnf below. Upgrade path: with the old plain login file and a backup: true copy planted on all four VMs, the next converge removed both, and the dump and the /etc check passed. On the VMs: Rocky 8 has /etc/credstore/mariadb-dump-login.cnf (0600 root), Rocky 9 the ciphertext in /etc/credstore.encrypted/ and LoadCredentialEncrypted= on the unit.

The first idempotence run failed once on Rocky 9 in repo_mydumper (copy /tmp/ansible.mydumper.asc: the key fetched from keyserver.ubuntu.com differed between runs); unrelated, the rerun was green.

@NavidSassan
NavidSassan force-pushed the feat/mariadb-dump-credential branch from 94b45cd to 7c6da16 Compare October 28, 2026 10:40
@NavidSassan
NavidSassan force-pushed the feat/mariadb-dump-credential branch from 3f1019d to 1cd7991 Compare October 28, 2026 11:01
/usr/local/bin/mariadb-dump shadowed MariaDB's own mariadb-dump client in
PATH. The script only works when started by mariadb-dump.service anyway.
@NavidSassan
NavidSassan merged commit ea60f1e into main Oct 29, 2026
13 checks passed
@NavidSassan
NavidSassan deleted the feat/mariadb-dump-credential branch October 29, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant