Added auto seeding of credentials

This commit is contained in:
Kevin Veen-Birkenbach 2025-07-21 17:52:19 +02:00
parent 809ac1adf4
commit c185c537cb
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E

View File

@ -42,14 +42,52 @@ for app in $apps; do
if [ "$rc" -eq 0 ]; then if [ "$rc" -eq 0 ]; then
echo "✅ Credentials generated for $app" echo "✅ Credentials generated for $app"
else elif echo "$output" | grep -q "No such file or directory"; then
if echo "$output" | grep -q "No such file or directory.*schema/main.yml" || \ echo "⚠️ Skipping $app (no schema/config)"
echo "$output" | grep -q "No such file or directory.*config/main.yml"; then elif echo "$output" | grep -q "Plain algorithm for"; then
echo "⚠️ Skipping $app (no schema/config)" # Collect all plain-algo keys
keys=( $(echo "$output" | grep -oP "Plain algorithm for '\K[^']+") )
overrides=()
for key in "${keys[@]}"; do
if [[ "$key" == *api_key ]]; then
val=$(python3 - << 'PY'
import random, string
print(''.join(random.choices(string.ascii_letters+string.digits, k=32)))
PY
)
elif [[ "$key" == *password ]]; then
val=$(python3 - << 'PY'
import random, string
print(''.join(random.choices(string.ascii_letters+string.digits, k=12)))
PY
)
else
val=$(python3 - << 'PY'
import random, string
print(''.join(random.choices(string.ascii_letters+string.digits, k=16)))
PY
)
fi
echo " → Overriding $key=$val"
overrides+=("--set" "$key=$val")
done
# Retry with overrides
echo "🔄 Retrying with overrides..."
retry_out=$(python3 -m cli.create.credentials \
--role-path "/repo/roles/$app" \
--inventory-file "$ART/inventory.yml" \
--vault-password-file "$ART/vaultpw.txt" \
"${overrides[@]}" \
--force 2>&1) || retry_rc=$?; retry_rc=${retry_rc:-0}
if [ "$retry_rc" -eq 0 ]; then
echo "✅ Credentials generated for $app (with overrides)"
else else
echo "❌ Credential error for $app:" echo "Override failed for $app:"
echo "$output" echo "$retry_out"
fi fi
else
echo "❌ Credential error for $app:"
echo "$output"
fi fi
done done