32 lines
1004 B
Python
32 lines
1004 B
Python
import paramiko
|
|
|
|
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
|
|
|
def apply_manifest(host, local_file):
|
|
with open(local_file, "r") as f:
|
|
manifest_content = f.read()
|
|
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect(host, username="root", key_filename=SSH_KEY, timeout=10)
|
|
|
|
stdin, stdout, stderr = client.exec_command("k3s kubectl apply -f -")
|
|
stdin.write(manifest_content)
|
|
stdin.close()
|
|
out = stdout.read().decode()
|
|
err = stderr.read().decode()
|
|
client.close()
|
|
return out, err
|
|
|
|
print("=== Applying to Aerodrome (140.44.4.11) ===")
|
|
out, err = apply_manifest("140.44.4.11", r"homelab-gitops-repo\manifests\aerodrome\dns\dns-stack.yaml")
|
|
print(out)
|
|
if err:
|
|
print("Stderr:", err)
|
|
|
|
print("=== Applying to Spaceport (140.44.4.41) ===")
|
|
out, err = apply_manifest("140.44.4.41", r"homelab-gitops-repo\manifests\spaceport\dns\dns-stack.yaml")
|
|
print(out)
|
|
if err:
|
|
print("Stderr:", err)
|