feat(plugins): plugin capability registry + host_agent→Ansible deploy synergy
Implements #253's framework: a small core capability registry (steward/core/capabilities.py) where a module/plugin publishes a named, role-gated action and a consumer discovers it via has_capability() and runs it via invoke_capability() — no hard import, graceful degradation, permission propagation (actor role checked against the capability's required_role). Core publishes "ansible.run_playbook" (operator) wrapping ansible.runner. trigger_run (extended to accept a caller-built inventory). First consumer: the host_agent plugin gains "Deploy via Ansible" on its settings page — pick an inventory target/group and it installs/updates the agent via the bundled host_agent/install.yml, minting a fresh token per host and injecting it as an inventory hostvar (turning per-host curl|sh into one run). Exposed role ordering as middleware.role_meets. Unit tests for the registry + role checks. Task #253 (milestone #37). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -123,6 +123,19 @@ def create_app(
|
||||
register_status_source(ping_status_source)
|
||||
register_status_source(dns_status_source)
|
||||
|
||||
# Publish the Ansible "run a playbook" capability so plugins (e.g. host_agent
|
||||
# auto-deploy) can drive runs without importing the runner. Ansible is core,
|
||||
# so this is always available; consumers still gate on has_capability().
|
||||
from .core.capabilities import register_capability
|
||||
from .ansible.runner import trigger_run
|
||||
from .models.users import UserRole as _UserRole
|
||||
register_capability(
|
||||
"ansible.run_playbook", trigger_run,
|
||||
label="Run Ansible playbook",
|
||||
description="Launch an Ansible playbook run (manual, alert, schedule, or plugin-driven).",
|
||||
required_role=_UserRole.operator,
|
||||
)
|
||||
|
||||
# ── 8. Build task registry ─────────────────────────────────────────────────
|
||||
app._task_registry = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user