aoh

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

commit f8a2fcbd4891fc430191cac1c614f5a630b3c853
parent 949158f81d380fef8e077dcf335f4c17dea65719
Author: Asher Morgan <asher@ashermorgan.net>
Date:   Fri, 14 Aug 2026 19:11:07 -0700

Add basic install script

Diffstat:
Ainstall.py | 22++++++++++++++++++++++
Mmain.py | 13++++++++++---
Mrequirements.txt | 1+
3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/install.py b/install.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import requests # TODO: eliminate dependency? +import time + +API = 'http://localhost:5000' + +res = requests.post(f'{API}/runners/', json={ + 'host': 'localhost', +}) + +assert res.status_code == 201 + +job_url = f'{API}{res.headers['Location']}' + +while True: + status = requests.get(job_url, cookies=res.cookies).content + print(f'Status: {status.decode()}') + + if status not in [b'started', b'running']: + break + time.sleep(1) diff --git a/main.py b/main.py @@ -1,7 +1,7 @@ import os import ansible_runner -from flask import Flask, abort, redirect, session +from flask import Flask, abort, make_response, request, send_file, session DATA = {} @@ -11,15 +11,22 @@ app = Flask(__name__) app.secret_key = b'_5#y2L"F4Q8z\n\xec]/' # TODO -@app.route('/runners/new') +@app.get('/install') +@app.get('/install.py') +def install(): + return send_file('install.py') + + +@app.post('/runners/') def job_new(): _, r = ansible_runner.run_async(private_data_dir='private', + limit=request.json['host'], playbook=PLAYBOOK) id = r.config.ident DATA[id] = r session['runner'] = id - return redirect(f'/runners/{id}') + return make_response('', 201, {'Location': f'/runners/{id}'}) @app.route('/runners/<id>') diff --git a/requirements.txt b/requirements.txt @@ -1,2 +1,3 @@ ansible_runner flask +requests