mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-10 04:36:40 +00:00
The validator cut every !vault block with a regex that ran up to the next line at column 0, so the keys after a vaulted password vanished, a whole user among them. utils.cache.yaml has parsed the !vault tag itself since c4556fe72d, so the loader now hands the file to it unchanged and a vaulted value loads as its ciphertext. An inventory-only user that brings its own username no longer warns as unknown.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
22 lines
738 B
Python
22 lines
738 B
Python
"""User-block validation: inventory user keys vs declared user defaults."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
|
|
def compare_user_keys(users, user_defaults, source) -> list[str]:
|
|
errs: list[str] = []
|
|
for user, conf in users.items():
|
|
if user not in user_defaults:
|
|
if not (isinstance(conf, dict) and conf.get("username")):
|
|
print(f"Warning: {source}: Unknown user '{user}'", file=sys.stderr)
|
|
continue
|
|
def_conf = user_defaults[user]
|
|
for key in conf:
|
|
if key in ("password", "credentials"):
|
|
continue
|
|
if key not in def_conf:
|
|
errs.append(f"Missing default for user '{user}': key '{key}'")
|
|
return errs
|