prole/etc/lib/shell/knoe_yaml.sh
chrisfu e75e03fb3f fix(rebrand): rename prole_*.sh shell libs to knoe_*.sh
check_kerberos.sh (already updated) sourced knoe_env.sh, knoe_secrets.sh,
knoe_string.sh, and knoe_yaml.sh but the files were still named prole_*.sh.
No other script referenced the old names, so this is a pure rename.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-03 14:57:09 -07:00

19 lines
417 B
Bash

#!/usr/bin/env bash
# Extract a simple scalar `key: value` from a YAML file.
# - Intended for flat `group_vars` style YAML only (no nesting).
# - Strips surrounding quotes.
knoe_yaml_get_scalar() {
local file="$1"
local key="$2"
awk -F: -v k="$key" '
$0 ~ "^[[:space:]]*"k"[[:space:]]*:" {
sub(/^[^:]+:[[:space:]]*/, "", $0);
gsub(/\"/, "", $0);
print $0;
exit
}
' "$file"
}