feat: add various infrastructure check and automation scripts

This commit is contained in:
2026-11-15 17:17:41 -05:00
parent 336b7759d0
commit b301aa3ece
232 changed files with 8274 additions and 298 deletions

View File

@@ -1,27 +1,35 @@
import paramiko
import sys
import json
sys.stdout.reconfigure(encoding='utf-8')
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("140.44.4.11", username="root", key_filename=key_path, timeout=5)
c.connect("140.44.4.41", username="root", key_filename=SSH_KEY, timeout=10)
cmd = "k3s kubectl -n infra exec authentik-postgresql-0 -- psql -U authentik -d authentik -c 'SELECT id, name, authorization_flow_id FROM authentik_core_application;'"
stdin, stdout, stderr = c.exec_command(cmd)
print("Authentik Applications:")
print(stdout.read().decode('utf-8'))
def k8s(cmd):
full_cmd = f"kubectl {cmd}"
_, o, e = c.exec_command(full_cmd)
return o.read().decode().strip(), e.read().decode().strip()
cmd2 = "k3s kubectl -n infra exec authentik-postgresql-0 -- psql -U authentik -d authentik -c 'SELECT id, name, external_host FROM authentik_providers_proxy_proxyprovider;'"
stdin, stdout, stderr = c.exec_command(cmd2)
print("Authentik Proxy Providers:")
print(stdout.read().decode('utf-8'))
print("Authentik pods:")
out, _ = k8s("get pods -A | grep -i authentik")
print(out)
cmd3 = "k3s kubectl -n infra exec authentik-postgresql-0 -- psql -U authentik -d authentik -c 'SELECT id, name, client_id FROM authentik_providers_oauth2_oauth2provider;'"
stdin, stdout, stderr = c.exec_command(cmd3)
print("Authentik OAuth2/OIDC Providers:")
print(stdout.read().decode('utf-8'))
# Check Authentik pod name
pod = ""
for line in out.splitlines():
if "server" in line:
pod = line.split()[1]
break
print("Authentik server pod:", pod)
if pod:
# Query Authentik applications and proxy providers via manage.py or python
out, err = k8s(f"exec -n authentik {pod} -- ak list_apps 2>/dev/null || kubectl exec -n authentik {pod} -- python -m authentik.manage shell -c 'from authentik.core.models import Application; print([(a.name, a.slug) for a in Application.objects.all()])'")
print("Applications:", out, err)
# Query Authentik proxy providers
out, err = k8s(f"exec -n authentik {pod} -- python -m authentik.manage shell -c 'from authentik.providers.proxy.models import ProxyProvider; print([(p.name, p.external_host) for p in ProxyProvider.objects.all()])'")
print("Proxy Providers:", out, err)
c.close()