mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-27 03:21:57 -06:00
Minor Changes
This commit is contained in:
@@ -92,7 +92,8 @@ class Role:
|
|||||||
self._runs = {} # run_id -> { proc, task, cancel }
|
self._runs = {} # run_id -> { proc, task, cancel }
|
||||||
self._svc_creds = None # cache per-process: {username, password}
|
self._svc_creds = None # cache per-process: {username, password}
|
||||||
try:
|
try:
|
||||||
os.makedirs(self._ansible_log_dir(), exist_ok=True)
|
base = os.path.join(_project_root(), 'Logs', 'Agent')
|
||||||
|
os.makedirs(base, exist_ok=True)
|
||||||
self._ansible_log(f"[init] PlaybookExec role init agent_id={ctx.agent_id}")
|
self._ansible_log(f"[init] PlaybookExec role init agent_id={ctx.agent_id}")
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -2699,15 +2699,18 @@ def ansible_quick_run():
|
|||||||
rel_path = (data.get("playbook_path") or "").strip()
|
rel_path = (data.get("playbook_path") or "").strip()
|
||||||
hostnames = data.get("hostnames") or []
|
hostnames = data.get("hostnames") or []
|
||||||
if not rel_path or not isinstance(hostnames, list) or not hostnames:
|
if not rel_path or not isinstance(hostnames, list) or not hostnames:
|
||||||
|
_ansible_log_server(f"[quick_run] invalid payload rel_path='{rel_path}' hostnames={hostnames}")
|
||||||
return jsonify({"error": "Missing playbook_path or hostnames[]"}), 400
|
return jsonify({"error": "Missing playbook_path or hostnames[]"}), 400
|
||||||
try:
|
try:
|
||||||
root, abs_path, _ = _resolve_assembly_path('ansible', rel_path)
|
root, abs_path, _ = _resolve_assembly_path('ansible', rel_path)
|
||||||
if not os.path.isfile(abs_path):
|
if not os.path.isfile(abs_path):
|
||||||
|
_ansible_log_server(f"[quick_run] playbook not found path={abs_path}")
|
||||||
return jsonify({"error": "Playbook not found"}), 404
|
return jsonify({"error": "Playbook not found"}), 404
|
||||||
try:
|
try:
|
||||||
with open(abs_path, 'r', encoding='utf-8', errors='replace') as fh:
|
with open(abs_path, 'r', encoding='utf-8', errors='replace') as fh:
|
||||||
content = fh.read()
|
content = fh.read()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
_ansible_log_server(f"[quick_run] read error: {e}")
|
||||||
return jsonify({"error": f"Failed to read playbook: {e}"}), 500
|
return jsonify({"error": f"Failed to read playbook: {e}"}), 500
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
@@ -2754,9 +2757,10 @@ def ansible_quick_run():
|
|||||||
"activity_job_id": job_id,
|
"activity_job_id": job_id,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
|
_ansible_log_server(f"[quick_run] emit ansible_playbook_run host='{host}' run_id={run_id} job_id={job_id} path={rel_path}")
|
||||||
socketio.emit("ansible_playbook_run", payload)
|
socketio.emit("ansible_playbook_run", payload)
|
||||||
except Exception:
|
except Exception as ex:
|
||||||
pass
|
_ansible_log_server(f"[quick_run] emit failed host='{host}' run_id={run_id} err={ex}")
|
||||||
results.append({"hostname": host, "run_id": run_id, "status": "Queued", "activity_job_id": job_id})
|
results.append({"hostname": host, "run_id": run_id, "status": "Queued", "activity_job_id": job_id})
|
||||||
return jsonify({"results": results})
|
return jsonify({"results": results})
|
||||||
except ValueError as ve:
|
except ValueError as ve:
|
||||||
|
|||||||
Reference in New Issue
Block a user