Files
computer-playbook/cli/administration/inventory/validate/users.py
T
kevinveenbirkenbachandClaude Opus 5.5 78678d220f fix(inventory/validate): keep the keys after a vaulted value
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>
2026-10-28 15:33:49 +01:00

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