33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
import paramiko
|
|
import time
|
|
|
|
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=10)
|
|
|
|
py_launch = """
|
|
from awx.main.models import JobTemplate
|
|
jt = JobTemplate.objects.get(name='Daily Drift & Agent Health Audit')
|
|
job = jt.create_unified_job()
|
|
job.signal_start()
|
|
print(f"Launched Job [{job.id}] for Template '{jt.name}': Status={job.status}")
|
|
"""
|
|
|
|
cmd = f"kubectl exec -i -n awx -c awx-task deployment/awx-task -- awx-manage shell_plus --quiet << 'EOF'\n{py_launch}\nEOF"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
|
print(stdout.read().decode())
|
|
|
|
time.sleep(15)
|
|
py_check = """
|
|
from awx.main.models import Job
|
|
job = Job.objects.filter(job_template__name='Daily Drift & Agent Health Audit').order_by('-id').first()
|
|
if job:
|
|
print(f"Job [{job.id}]: Status={job.status}, Elapsed={job.elapsed}s")
|
|
"""
|
|
cmd = f"kubectl exec -i -n awx -c awx-task deployment/awx-task -- awx-manage shell_plus --quiet << 'EOF'\n{py_check}\nEOF"
|
|
stdin, stdout, stderr = ssh.exec_command(cmd)
|
|
print(stdout.read().decode())
|
|
|
|
ssh.close()
|
|
|