diff --git a/fablednetmon/ansible/routes.py b/fablednetmon/ansible/routes.py index 2ce9758..0da247c 100644 --- a/fablednetmon/ansible/routes.py +++ b/fablednetmon/ansible/routes.py @@ -1,5 +1,6 @@ # fablednetmon/ansible/routes.py from __future__ import annotations +import asyncio import uuid from datetime import datetime, timezone from pathlib import Path @@ -77,6 +78,9 @@ async def create_run(): source_name = form.get("source_name", "").strip() inventory_path = form.get("inventory_path", "").strip() + if not playbook_path or not inventory_path: + return "playbook_path and inventory_path are required", 400 + all_sources = _get_sources() source = next((s for s in all_sources if s["name"] == source_name), None) if source is None: @@ -98,8 +102,7 @@ async def create_run(): async with db.begin(): db.add(run) - import asyncio - asyncio.create_task( + task = asyncio.create_task( executor.start_run( current_app._get_current_object(), # type: ignore[attr-defined] run_id, @@ -108,6 +111,11 @@ async def create_run(): source["path"], ) ) + task.add_done_callback( + lambda t: t.exception() and current_app.logger.error( + "Ansible run %s raised: %s", run_id, t.exception() + ) + ) return await render_template( "ansible/run_started.html", diff --git a/fablednetmon/templates/ansible/browse.html b/fablednetmon/templates/ansible/browse.html index fbd64ea..19f5e2b 100644 --- a/fablednetmon/templates/ansible/browse.html +++ b/fablednetmon/templates/ansible/browse.html @@ -87,7 +87,7 @@
--
++