mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-07-22 16:21:09 +02:00
Added auto seeding of credentials
This commit is contained in:
parent
809ac1adf4
commit
c185c537cb
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user