23 lines
895 B
Python
23 lines
895 B
Python
import paramiko
|
|
import sys
|
|
import base64
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
|
|
|
def apply_manifest(host, file_path):
|
|
with open(file_path, "rb") as f:
|
|
b64 = base64.b64encode(f.read()).decode('ascii')
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(host, username="root", key_filename=key_path, timeout=5)
|
|
stdin, stdout, stderr = c.exec_command(f"echo '{b64}' | base64 -d | k3s kubectl apply -f -")
|
|
print(f"Apply on {host}:")
|
|
print(stdout.read().decode('utf-8'))
|
|
c.close()
|
|
|
|
apply_manifest("140.44.4.11", r"C:\Users\Snarf\OneDrive\Desktop\code\SnarfCode\homelab-gitops-repo\manifests\aerodrome\dns\dns-stack.yaml")
|
|
apply_manifest("140.44.4.41", r"C:\Users\Snarf\OneDrive\Desktop\code\SnarfCode\homelab-gitops-repo\manifests\spaceport\dns\dns-stack.yaml")
|
|
|