aoh

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

commit 3d39709d640e4bcb65634d240a703742fa0f2846
parent 39e55ba4681751a0f8936a79f2b6f5f497b4e248
Author: Asher Morgan <asher@ashermorgan.net>
Date:   Fri, 18 Sep 2026 18:39:52 -0700

Run ansible commands inside playbook directory

Diffstat:
MREADME.md | 6++++--
Maoh/config.py | 1+
Maoh/runner.py | 4+++-
3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md @@ -133,8 +133,10 @@ variables. `./passwords.yml` otherwise. - `AOH_PLAYBOOKS_FILE`: The file containing playbook configuration (see the - [playbooks](#playbooks) section below). Defaults to `/aoh/playbooks.yml` when - running the Docker image and `./playbooks.yml` otherwise. + [playbooks](#playbooks) section below). The parent directory of this file is + also used as the working directory for all Ansible operations. Defaults to + `/aoh/playbooks.yml` when running the Docker image and `./playbooks.yml` + otherwise. ### Playbooks diff --git a/aoh/config.py b/aoh/config.py @@ -36,6 +36,7 @@ if AOH_ORIGIN is not None: AOH_PLAYBOOKS_FILE = os.getenv('AOH_PLAYBOOKS_FILE', 'playbooks.yml') if not os.path.exists(AOH_PLAYBOOKS_FILE): logger.warning('$AOH_PLAYBOOKS_FILE does not exist') +AOH_PLAYBOOKS_DIR = os.path.dirname(AOH_PLAYBOOKS_FILE) AOH_PASSWORDS_FILE = os.getenv('AOH_PASSWORDS_FILE', 'passwords.yml') if not os.path.exists(AOH_PASSWORDS_FILE): diff --git a/aoh/runner.py b/aoh/runner.py @@ -10,7 +10,7 @@ import uuid import ansible_runner -from aoh.config import AOH_DEBUG +from aoh.config import AOH_DEBUG, AOH_PLAYBOOKS_DIR _CONNECTION_PLUGIN_DIR = f'{os.path.dirname(__file__)}/connection_plugins/' @@ -35,6 +35,7 @@ def get_config_values(playbook, keys): raw_config = ansible_runner.get_ansible_config( 'dump', + host_cwd=AOH_PLAYBOOKS_DIR, envvars=env, private_data_dir=dir, quiet=True, @@ -148,6 +149,7 @@ class Runner: self._thread, self._runner = ansible_runner.run_async( private_data_dir=self._DIR, ident=self.id, + host_cwd=AOH_PLAYBOOKS_DIR, envvars=env, cmdline=cmdline, limit=self.playbook.host if self.playbook.limit else None,