aoh

A tool for running Ansible playbooks with `curl <url> | python` commands
git clone https://git.ashermorgan.net/aoh/
Log | Files | Refs | README

commit ea8c18e2d6d088bbc555a1c9b292b2be28c154dd
parent db5a7846c6ae76987a470b16c98bdf17c04282cb
Author: Asher Morgan <asher@ashermorgan.net>
Date:   Sat, 15 Aug 2026 16:09:59 -0700

Send logs to client

Diffstat:
Minstall.py | 9+++------
Mmain.py | 6+++++-
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/install.py b/install.py @@ -11,8 +11,6 @@ API = 'http://localhost:5000' def exec(args): - print(f'EXEC {args}') - try: p = subprocess.Popen( args, @@ -32,8 +30,6 @@ def exec(args): def put(args): - print(f"PUT {args['dest']} ({len(args['data'])} bytes)") - try: with open(args['dest'], 'wb') as f: f.write(base64.b64decode(args['data'])) @@ -44,8 +40,6 @@ def put(args): def fetch(args): - print(f"PUT {args['dest']} ({len(args['data'])} bytes)") - try: with open(args['dest'], 'rb') as f: return { @@ -67,6 +61,9 @@ def main(): while True: res = requests.put(job_url, cookies=cookies, json=req).json() + if 'logs' in res: + print(res['logs'], end='') + req = {} if res['status'] not in ['started', 'running']: break diff --git a/main.py b/main.py @@ -27,6 +27,7 @@ class Runner: self.sendbuf = open(f'{self.dir}/sendbuf', 'r') self.recvbuf = open(f'{self.dir}/recvbuf', 'w') + self.logs = open(f'{self.dir}/artifacts/{self.id}/stdout', 'r') def _start(self, host, playbook): inv = { @@ -55,7 +56,8 @@ class Runner: envvars=env, playbook=playbook, ident=self.id, - verbosity=3 + verbosity=3, + quiet=True, ) def teardown(self): @@ -63,6 +65,7 @@ class Runner: self.id = None self.sendbuf.close() self.recvbuf.close() + self.logs.close() shutil.rmtree(self.dir) @@ -94,6 +97,7 @@ def job_status(id): res = json.loads(runner.sendbuf.readline() or '{}') res['status'] = runner.runner.status + res['logs'] = runner.logs.read() if runner.runner.status not in ['started', 'running']: runner.teardown()