feat: add various infrastructure check and automation scripts
This commit is contained in:
46
scripts/run_ak_standalone.py
Normal file
46
scripts/run_ak_standalone.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import paramiko
|
||||
|
||||
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=SSH_KEY, timeout=10)
|
||||
|
||||
pod = "authentik-server-cd7d9b949-vfl2m"
|
||||
|
||||
script_content = """import os
|
||||
import django
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'authentik.root.settings')
|
||||
django.setup()
|
||||
|
||||
from authentik.core.models import Application
|
||||
from authentik.providers.proxy.models import ProxyProvider
|
||||
from authentik.policies.models import PolicyBindingModel, Policy
|
||||
|
||||
print("=== APPLICATIONS ===")
|
||||
for a in Application.objects.all():
|
||||
print(f"App: {a.name} (slug: {a.slug}) | Provider: {a.provider}")
|
||||
|
||||
print("\\n=== PROXY PROVIDERS ===")
|
||||
for p in ProxyProvider.objects.all():
|
||||
print(f"Provider: {p.name} | External: {p.external_host} | Mode: {p.mode}")
|
||||
|
||||
print("\\n=== POLICIES ===")
|
||||
for p in Policy.objects.all():
|
||||
print(f"Policy: {p.name} ({p.__class__.__name__})")
|
||||
|
||||
print("\\n=== POLICY BINDINGS ===")
|
||||
for pb in PolicyBindingModel.objects.all():
|
||||
print(f"Target: {pb.target} -> Policy: {pb.policy}")
|
||||
"""
|
||||
|
||||
stdin, stdout, stderr = c.exec_command("cat > /tmp/ak_standalone.py")
|
||||
stdin.write(script_content)
|
||||
stdin.close()
|
||||
stdout.channel.recv_exit_status()
|
||||
|
||||
c.exec_command(f"kubectl cp /tmp/ak_standalone.py infra/{pod}:/tmp/ak_standalone.py -c server")
|
||||
_, o, e = c.exec_command(f"kubectl exec -n infra {pod} -c server -- /ak-root/.venv/bin/python3 /tmp/ak_standalone.py")
|
||||
print("OUTPUT:\n", o.read().decode())
|
||||
|
||||
c.close()
|
||||
|
||||
Reference in New Issue
Block a user