24 lines
764 B
Python
24 lines
764 B
Python
import paramiko
|
|
import sys
|
|
|
|
sys.stdout.reconfigure(encoding='utf-8')
|
|
|
|
ssh = paramiko.SSHClient()
|
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
ssh.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=8)
|
|
|
|
py_code = """
|
|
from awx.main.models import JobTemplate
|
|
jt = JobTemplate.objects.get(id=10)
|
|
print(f"Name: {jt.name}")
|
|
print(f"Playbook: {jt.playbook}")
|
|
print(f"Inventory: {jt.inventory.name if jt.inventory else None}")
|
|
print(f"Credential: {[c.name for c in jt.credentials.all()]}")
|
|
"""
|
|
|
|
cmd = f"kubectl exec -i -n awx -c awx-task deployment/awx-task -- awx-manage shell_plus --quiet << 'EOF'\n{py_code}\nEOF"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
|
print(stdout.read().decode())
|
|
ssh.close()
|
|
|