aoh

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

commit 1ce74e1e882578209503e3242747a079cb7fbe7d
parent 0b0d4036e9d17dae144f46b05cdacc25c2193af5
Author: Asher Morgan <asher@ashermorgan.net>
Date:   Sun, 23 Aug 2026 14:53:09 -0700

Implement AOH_PLAYBOOKS_{DIR,FILE} env variables

Diffstat:
M.gitignore | 7++++---
Maoh/__main__.py | 3+++
Maoh/playbook.py | 10+++++-----
Mrequirements.txt | 1+
4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,4 +1,5 @@ -.venv -__pycache__ +.env +playbooks.yml *.pyc -config.yml +__pycache__ +.venv diff --git a/aoh/__main__.py b/aoh/__main__.py @@ -1,4 +1,7 @@ +from dotenv import load_dotenv + from .server import app, scheduler +load_dotenv() scheduler.start() app.run(debug=True) diff --git a/aoh/playbook.py b/aoh/playbook.py @@ -4,7 +4,8 @@ import tempfile import ansible_runner import yaml -CONFIG_FILE = 'config.yml' # TODO: make configurable +PLAYBOOKS_FILE = os.getenv('AOH_PLAYBOOKS_FILE', 'playbooks.yml') +PLAYBOOKS_DIR = os.getenv('AOH_PLAYBOOKS_DIR', os.path.dirname(PLAYBOOKS_FILE)) _CLI_OPT_WHITELIST = [ # These options should be safe for clients to invoke @@ -95,9 +96,8 @@ class Playbook: self.allow_opts = dict.get('allow_opts', []) self.block_opts = dict.get('block_opts', []) - # TODO: allow a default playbook dir to be specified? - self.path = os.path.abspath(self.path) - self.config = os.path.abspath(self.config) + self.path = os.path.abspath(os.path.join(PLAYBOOKS_DIR, self.path)) + self.config = os.path.abspath(os.path.join(PLAYBOOKS_DIR, self.config)) def validate_args(self, args): @@ -147,7 +147,7 @@ class Playbook: def get_playbook(name): """Lookup a playbook configuration.""" - with open(CONFIG_FILE, 'r') as f: + with open(PLAYBOOKS_FILE, 'r') as f: CONFIG = yaml.safe_load(f) if name in CONFIG: return Playbook(name, CONFIG[name]) diff --git a/requirements.txt b/requirements.txt @@ -1,4 +1,5 @@ ansible ansible_runner flask +python-dotenv pyyaml