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) # Write to remote /tmp/dns-stack.yaml and kubectl apply sftp = client.open_sftp() with sftp.open("/tmp/dns-stack.yaml", "w") as f: f.write(manifest_content) sftp.close() stdin, stdout, stderr = client.exec_command("k3s kubectl apply -f /tmp/dns-stack.yaml") 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)