aoh

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

commit 74e842e0151470e0fe4c8c1f9bced51a2c7e0d35
parent c132a4c6d846ddd12a54c72bce101a046d8a4944
Author: Asher Morgan <asher@ashermorgan.net>
Date:   Sat, 29 Aug 2026 15:37:54 -0700

Implement host and groups playbook options

Diffstat:
Maoh/client.py | 2+-
Maoh/playbook.py | 4++++
Maoh/runner.py | 10++++++----
3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/aoh/client.py b/aoh/client.py @@ -145,7 +145,7 @@ def create_runner(playbook, args): url = f'{API}/runners/' req = { - 'host': platform.node() or 'aoh_node', + 'host': platform.node(), 'playbook': playbook, 'args': args, } diff --git a/aoh/playbook.py b/aoh/playbook.py @@ -18,6 +18,8 @@ class Playbook: _types = { 'path': str, 'config': str, + 'host': str, + 'groups': list, 'password': bool, 'cmdline': str, 'output': bool, @@ -33,6 +35,8 @@ class Playbook: self.name = name self.path = dict.get('path', name) self.config = dict.get('config', None) + self.host = dict.get('host') + self.groups = dict.get('groups', []) self.password = dict.get('password', False) self.cmdline = dict.get('cmdline', '') self.output = dict.get('output', True) diff --git a/aoh/runner.py b/aoh/runner.py @@ -29,6 +29,7 @@ class Runner: self.id = str(uuid4()) # Runner ID (set to None after teardown) self.playbook = playbook + self.host = self.playbook.host or host or 'aoh_node' self._lock = Lock() # Used to protect all public methods @@ -48,9 +49,9 @@ class Runner: try: # Create hostname file so connection plugin can verify hosts with open(f'{self._DIR}/hostname', 'w') as f: - f.write(f'{host}\n') + f.write(f'{self.host}\n') - self._start_runner(host, args, passwords) + self._start_runner(args, passwords) # We assume that ansible-runner will eventually create its log file while not os.path.exists(self._LOGS_PATH): @@ -61,14 +62,15 @@ class Runner: raise - def _start_runner(self, host, args, passwords): + def _start_runner(self, args, passwords): """Configure and start the underlying ansible-runner.""" # Set ansible_connection=aoh for the client host only. Note that we # don't use ansible-runner's inventory directory because that will # shadow user inventory files. with open(f'{self._DIR}/inventory.ini', 'w') as f: - f.write(f'[aoh]\n{host} ansible_connection=aoh') + f.write(f'[aoh]\n{self.host} ansible_connection=aoh\n') + f.writelines(f'[{g}]\n{self.host}\n' for g in self.playbook.groups) raw_config = ansible_runner.get_ansible_config( 'dump',