aoh

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

commit 49d5d4228d90e627e853ca5fa591f198d2c93410
parent e6d49badfd6b7a55c3e4d55d426862ed5817da85
Author: Asher Morgan <asher@ashermorgan.net>
Date:   Fri, 21 Aug 2026 19:06:19 -0700

Ensure ansible cmdline is correctly quoted

Diffstat:
Maoh/client.py | 2+-
Maoh/runner.py | 3++-
Maoh/server.py | 11+++++------
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/aoh/client.py b/aoh/client.py @@ -62,7 +62,7 @@ def main(): res = requests.post(f'{API}/runners/', json={ 'host': platform.node() or 'aoh_node', 'playbook': sys.argv[1] if len(sys.argv) >= 2 else 'main', - 'args': ' '.join(sys.argv[2:]), + 'args': sys.argv[2:], }) if res.status_code != 201: print(res.json()['err']) diff --git a/aoh/runner.py b/aoh/runner.py @@ -1,5 +1,6 @@ import json import os +import shlex import shutil import tempfile import time @@ -107,7 +108,7 @@ class AoHRunner: ident=self.id, envvars=env, extravars=vars, - cmdline=args, + cmdline=' '.join(shlex.quote(arg) for arg in args), playbook=playbook, diff --git a/aoh/server.py b/aoh/server.py @@ -28,9 +28,9 @@ def gc(): _RUNNERS.pop(id, None) -def _get_opts(cmdline): +def _get_opts(args): opts = [] - for arg in cmdline.split(): + for arg in args: if arg.startswith('--'): opts += [arg.split('=')[0]] elif arg.startswith('-'): @@ -39,9 +39,9 @@ def _get_opts(cmdline): return opts -def _validate_args(cmdline): +def _validate_args(args): # Reject any sign of Jinja expressions - if '{{' in cmdline or '{%' in cmdline: + if '{{' in ' '.join(args) or '{%' in ' '.join(args): return False # Enforce whitelisted options. Other options either might not be supported @@ -60,9 +60,8 @@ def _validate_args(cmdline): '--verbose', '-v', '--version', ] - for opt in _get_opts(cmdline): + for opt in _get_opts(args): if opt not in OPT_WHITELIST: - print('bad', opt) return False return True